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 195, Fri Feb 18 12:30:30 2011 UTC revision 196, Fri Feb 18 12:52:48 2011 UTC
# Line 9  Line 9 
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)[!toadd]    toup <- names(y)[!toadd]
12    if("doc"%in%names(x))return(x$doc)    ##if("doc"%in%names(x))return(x$doc)
13    if("doc"%in%names(y))return(y$doc)    ##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 512  Line 512 
512             }             }
513             list(examples = ex)             list(examples = ex)
514           } else list()           } else list()
515         },         }
516         collapse.docs=function(doc,...){         )
          list(doc=lapply(doc,paste,collapse="\n"))  
        })  
517    
518  ### List of parser functions that operate on single objects. This list  ### List of parser functions that operate on single objects. This list
519  ### is useful for testing these functions.  ### is useful for testing these functions.
520  lonely <- c(forall.parsers,forfun.parsers)  lonely <- structure(c(forall.parsers,forfun.parsers),ex=function(){
 attr(lonely,"ex") <- function(){  
521    f <- function # title    f <- function # title
522  ### description  ### description
523    (x, ##<< arg x    (x, ##<< arg x
# Line 536  Line 533 
533    src <- attr(f,"source")    src <- attr(f,"source")
534    lonely$extract.xxx.chunks(src)    lonely$extract.xxx.chunks(src)
535    lonely$prefixed.lines(src)    lonely$prefixed.lines(src)
536  }  })
537    
538  extra.code.docs <- function # Extract documentation from code chunks  extra.code.docs <- function # Extract documentation from code chunks
539  ### Parse R code to extract inline documentation from comments around  ### Parse R code to extract inline documentation from comments around
# Line 659  Line 656 
656  default.parsers <-  default.parsers <-
657    c(extra.code.docs=extra.code.docs, ## TODO: cleanup!    c(extra.code.docs=extra.code.docs, ## TODO: cleanup!
658      sapply(forfun.parsers,forfun),      sapply(forfun.parsers,forfun),
659        sapply(forall.parsers,forall),
660      edit.package.file=function(desc,...){      edit.package.file=function(desc,...){
661        in.details <- setdiff(colnames(desc),"Description")        in.details <- setdiff(colnames(desc),"Description")
662        details <- sprintf("%s: \\tab %s\\cr",in.details,desc[,in.details])        details <- sprintf("%s: \\tab %s\\cr",in.details,desc[,in.details])
# Line 668  Line 666 
666                    `tabular{ll}`=details))                    `tabular{ll}`=details))
667        names(L) <- paste(desc[,"Package"],"-package",sep="")        names(L) <- paste(desc[,"Package"],"-package",sep="")
668        L        L
669      },      }
     sapply(forall.parsers,forall)  
670      )      )
671    
672  setClass("DocLink", # Link documentation among related functions  setClass("DocLink", # Link documentation among related functions
# Line 895  Line 892 
892      L <- p(code=code,objs=objs,docs=docs,...)      L <- p(code=code,objs=objs,docs=docs,...)
893      docs <- combine(docs,L)      docs <- combine(docs,L)
894    }    }
895      ## post-process to collapse all character vectors
896      for(i in seq_along(docs)){
897        for(j in seq_along(docs[[i]])){
898          docs[[i]][[j]] <- paste(docs[[i]][[j]],collapse="\n")
899        }
900      }
901    if(verbose)cat("\n")    if(verbose)cat("\n")
902    docs    docs
903  ### A list of extracted documentation from code.  ### A list of extracted documentation from code.

Legend:
Removed from v.195  
changed lines
  Added in v.196

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