SCM

SCM Repository

[inlinedocs] Diff of /pkg/inlinedocs/R/parsers.R
ViewVC logotype

Diff of /pkg/inlinedocs/R/parsers.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 109, Mon Jun 7 08:42:15 2010 UTC revision 110, Mon Jun 7 12:08:54 2010 UTC
# Line 1  Line 1 
1    ### combine lists or character strings
2    combine <- function(x,y)UseMethod("combine")
3    
4    ### combine character strings by pasting them together
5    combine.character <- function(x,y)
6        paste(x,y,sep="\n")
7    
8    ### combine lists by adding elements or adding to existing elements
9    combine.list <- function(x,y){
10      toadd <- !names(y)%in%names(x)
11      toup <- names(y)[names(y)%in%names(x)]
12      x[names(y)[toadd]] <- y[toadd]
13      for(up in toup)x[[up]] <- combine(x[[up]],y[[up]])
14      return(x)
15    ### A list, same type as x, but with added elements from y.
16    }
17    
18    ### Prefix for code comments used with grep and gsub.
19    prefix <- "^[ \t]*###[ \t]"
20    
21    decomment <- function
22    ### Remove comment prefix and join lines of code to form a
23    ### documentation string.
24    (comments
25    ### Character vector of prefixed comment lines.
26     ){
27      paste(gsub(prefix,"",comments),collapse="\n")
28    ### String without prefixes or newlines.
29    }
30    
31  ### For each object in the package that satisfies the criterion  ### For each object in the package that satisfies the criterion
32  ### checked by subfun, parse source using FUN and return the resulting  ### checked by subfun, parse source using FUN and return the resulting
33  ### documentation list.  ### documentation list.
# Line 719  Line 749 
749  ### Additional arguments to pass to Parser Functions.  ### Additional arguments to pass to Parser Functions.
750   ){   ){
751    e <- new.env()    e <- new.env()
752    old <- options(keep.source.pkgs=TRUE)    old <- options(keep.source=TRUE)
753    on.exit(options(old))    on.exit(options(old))
   ##tryCatch({  
754      exprs <- parse(text=code)      exprs <- parse(text=code)
755      for (i in exprs) eval(i, e)      for (i in exprs) eval(i, e)
 ##   },error=function(err){  
 ##     print(i)  
 ##     stop("eval or parse failed with error:\n",err)  
 ##   })  
756    objs <- sapply(ls(e),get,e,simplify=FALSE)    objs <- sapply(ls(e),get,e,simplify=FALSE)
757    
758    docs <- list()    docs <- list()

Legend:
Removed from v.109  
changed lines
  Added in v.110

R-Forge@R-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge