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 175, Thu Jan 6 15:24:45 2011 UTC revision 185, Thu Jan 13 16:08:14 2011 UTC
# Line 8  Line 8 
8  ### combine lists by adding elements or adding to existing elements  ### combine lists by adding elements or adding to existing elements
9  combine.list <- function(x,y){  combine.list <- function(x,y){
10    toadd <- !names(y)%in%names(x)    toadd <- !names(y)%in%names(x)
11    toup <- names(y)[names(y)%in%names(x)]    toup <- names(y)[!toadd]
12      if("doc"%in%names(x))return(x$doc)
13      if("doc"%in%names(y))return(y$doc)
14    x[names(y)[toadd]] <- y[toadd]    x[names(y)[toadd]] <- y[toadd]
15    for(up in toup)x[[up]] <- combine(x[[up]],y[[up]])    for(up in toup)x[[up]] <- combine(x[[up]],y[[up]])
16    return(x)    return(x)
# Line 24  Line 26 
26  (comments  (comments
27  ### Character vector of prefixed comment lines.  ### Character vector of prefixed comment lines.
28   ){   ){
29    paste(gsub(prefix,"",comments),collapse="\n")    gsub(prefix,"",comments)
30  ### String without prefixes or newlines.  ### String without prefixes or newlines.
31  }  }
32    
# Line 132  Line 134 
134    ## Add an empty line before and after example    ## Add an empty line before and after example
135    ex <- c("", ex, "")    ex <- c("", ex, "")
136    ## Return examples and value    ## Return examples and value
137    list(examples = paste(ex, collapse = "\n"), value = value)    list(examples = ex, value = value)
138  }  }
139    
140  prefixed.lines <- structure(function(src,...){  prefixed.lines <- structure(function(src,...){
# Line 461  Line 463 
463           if (is.null(tsubdir)) tsubdir <- "tests"       # Default value           if (is.null(tsubdir)) tsubdir <- "tests"       # Default value
464           tfile <- file.path("..",tsubdir,paste(name,".R",sep=""))           tfile <- file.path("..",tsubdir,paste(name,".R",sep=""))
465           if(file.exists(tfile))           if(file.exists(tfile))
466             list(examples=paste(readLines(tfile),collapse="\n"))             list(examples=readLines(tfile))
467           else list()           else list()
468         },         },
469         definition.from.source=function(doc,src,...){         definition.from.source=function(doc,src,...){
470           def <- doc$definition           def <- doc$definition
471           is.empty <- function(x)is.null(x)||x==""           is.empty <- function(x)is.null(x)||x==""
472           if(is.empty(def) && !is.empty(src))           if(is.empty(def) && !is.empty(src))
473             list(definition=paste(src,collapse="\n"))             list(definition=src)
474           else list()           else list()
475         })         })
476    
# Line 507  Line 509 
509               ## Add an empty line before and after example               ## Add an empty line before and after example
510               ex <- c("", ex, "")               ex <- c("", ex, "")
511             }             }
512             list(examples = paste(ex, collapse = "\n"))             list(examples = ex)
513           } else list()           } else list()
514           },
515           collapse.docs=function(doc,...){
516             list(doc=lapply(doc,paste,collapse="\n"))
517         })         })
518    
519  ### List of parser functions that operate on single objects. This list  ### List of parser functions that operate on single objects. This list
# Line 555  Line 560 
560        doc <- list()        doc <- list()
561        if ( !is.null(parsed[[on]]) ){        if ( !is.null(parsed[[on]]) ){
562          if ( !is.na(parsed[[on]]@code[1]) ){ # no code given for generics          if ( !is.na(parsed[[on]]@code[1]) ){ # no code given for generics
563            doc$definition <- paste(parsed[[on]]@code,collapse="\n")            doc$definition <- paste(parsed[[on]]@code)
564          }          }
565          if(!"description"%in%names(doc) && !is.na(parsed[[on]]@description) ){          if(!"description"%in%names(doc) && !is.na(parsed[[on]]@description) ){
566            doc$description <- parsed[[on]]@description            doc$description <- parsed[[on]]@description
# Line 656  Line 661 
661      sapply(forall.parsers,forall),      sapply(forall.parsers,forall),
662      edit.package.file=function(desc,...){      edit.package.file=function(desc,...){
663        in.details <- setdiff(colnames(desc),"Description")        in.details <- setdiff(colnames(desc),"Description")
664        details <- paste(paste(in.details,": \\tab ",desc[,in.details],"\\cr",        details <- sprintf("%s: \\tab %s\\cr",in.details,desc[,in.details])
                              sep=""),collapse="\n")  
665        L <-        L <-
666          list(list(title=desc[,"Title"],          list(list(title=desc[,"Title"],
667                    description=desc[,"Description"],                    description=desc[,"Description"],

Legend:
Removed from v.175  
changed lines
  Added in v.185

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