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 115, Fri Jun 18 10:35:11 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 493  Line 523 
523        arg <- gsub(arg.pat,"\\\\item\\{\\1\\}",line,perl=TRUE)        arg <- gsub(arg.pat,"\\\\item\\{\\1\\}",line,perl=TRUE)
524        in.chunk <- TRUE        in.chunk <- TRUE
525        if ( not.describe ){        if ( not.describe ){
526            ## TDH 2010-06-18 For item{}s in the documentation list names,
527            ## we don't need to have a backslash before, so delete it.
528            arg <- gsub("^[\\]+","",arg)
529          cur.field <- gsub("...","\\dots",arg,fix=TRUE) ##special case for dots          cur.field <- gsub("...","\\dots",arg,fix=TRUE) ##special case for dots
530          payload <- comment          payload <- comment
531        } else {        } else {
# Line 719  Line 752 
752  ### Additional arguments to pass to Parser Functions.  ### Additional arguments to pass to Parser Functions.
753   ){   ){
754    e <- new.env()    e <- new.env()
755    old <- options(keep.source.pkgs=TRUE)    old <- options(keep.source=TRUE)
756    on.exit(options(old))    on.exit(options(old))
   ##tryCatch({  
757      exprs <- parse(text=code)      exprs <- parse(text=code)
758      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)  
 ##   })  
759    objs <- sapply(ls(e),get,e,simplify=FALSE)    objs <- sapply(ls(e),get,e,simplify=FALSE)
760    
761    docs <- list()    docs <- list()

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

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge