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 97, Mon May 3 16:07:46 2010 UTC revision 104, Tue May 18 16:35:08 2010 UTC
# Line 25  Line 25 
25  ### For each function in the package, do something.  ### For each function in the package, do something.
26  forfun <- function(FUN)forall(FUN,is.function)  forfun <- function(FUN)forall(FUN,is.function)
27    
28  ### Default parsers to use with package.skeleton.dx  ### Parsers for each object/function that are constructed
29    ### automatically. This is a named list, each element is a list of 2
30    ### elements: forfun/forall, then a parser function for an individual
31    ### object.
32  forall.parsers <-  forall.parsers <-
33    list(## Extract lots of info from normal functions.    list(## Extract lots of info from normal functions.
34         parsefun=list(forfun,function(src,name,...){         parsefun=list(forfun,function(src,name,...){
# Line 64  Line 67 
67                   "((?:\\n###[^\\n]*)+)",#comment value lines \\1                   "((?:\\n###[^\\n]*)+)",#comment value lines \\1
68                   "([\\w\\W]*)[}]",#examples \\2                   "([\\w\\W]*)[}]",#examples \\2
69                   sep="")                   sep="")
70           SEP <- "----------"           SEP <- "-/-/-/-/-=====-----"
71           REP <- paste("\\1",SEP,"\\2",sep="")           REP <- paste("\\1",SEP,"\\2",sep="")
72           r <- strsplit(gsub(FIND,REP,after,perl=TRUE),split=SEP)[[1]]           r <- strsplit(gsub(FIND,REP,after,perl=TRUE),split=SEP)[[1]]
73           l <- strsplit(r,split="\n")           l <- strsplit(r,split="\n")
          ##if(name=="dl.combine")browser()  
74           excode <- c(l[[2]],"")           excode <- c(l[[2]],"")
75             if(length(l)<2||paste(excode,collapse="")=="")return(list())
76           prefixes <- gsub("(\\s*).*","\\1",excode,perl=TRUE)[grep("\\w",excode)]           prefixes <- gsub("(\\s*).*","\\1",excode,perl=TRUE)[grep("\\w",excode)]
77           FIND <- prefixes[which.min(nchar(prefixes))]           FIND <- prefixes[which.min(nchar(prefixes))]
78           list(examples=paste(sub(FIND,"",excode),collapse="\n"),           list(examples=paste(sub(FIND,"",excode),collapse="\n"),
# Line 78  Line 81 
81    
82  ### List of parser functions that operate on single objects. This list  ### List of parser functions that operate on single objects. This list
83  ### is useful for testing these functions, ie  ### is useful for testing these functions, ie
84  ### lonely$parsefuns(attr(extract.docs.file,"src"),"extract.docs.file")  ### lonely$parsefun(attr(extract.docs.file,"source"),"extract.docs.file")
85  lonely <- sapply(forall.parsers,function(L)L[[2]])  lonely <- sapply(forall.parsers,function(L)L[[2]])
86    
87  extract.docs.file <- function # Extract documentation from a file  extract.docs.file <- function # Extract documentation from a file

Legend:
Removed from v.97  
changed lines
  Added in v.104

root@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