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 95, Mon May 3 14:22:42 2010 UTC revision 96, Mon May 3 15:57:03 2010 UTC
# Line 52  Line 52 
52           else list()           else list()
53         }),         }),
54         ## Get examples from inline definitions after return()         ## Get examples from inline definitions after return()
55         examples.after.return=list(forfun,function(src,...){         examples.after.return=list(forfun,function(name,src,...){
56           rline <- grep("^\\W*return[(]",src)           coll <- paste(src,collapse="\n")
57           if(length(rline)==0)return(list())           thispre <- gsub("^[\\^]","",prefix)
58           rline <- rline[length(rline)]           FIND <- paste("(return|UseMethod)[(][^\\n]*\\n",thispre,sep="")
59           comment.line.nums <- grep(prefix,src)           m <- regexpr(FIND,coll)
60           if(!(comment.end <- rline+1)%in%comment.line.nums)return(list())           if(m[1]==-1)return(list())
61           while(comment.end%in%comment.line.nums)comment.end <- comment.end+1           after <- substr(coll,m[1],nchar(coll))
62           excode <- src[comment.end:(length(src)-1)]           FIND <-
63           list(examples=paste(gsub("^\\W*","",excode),collapse="\n"))             paste("[^\\n]*",# rest of the return line
64                     "((?:\\n###[^\\n]*)+)",#comment value lines \\1
65                     "([\\w\\W]*)[}]",#examples \\2
66                     sep="")
67             SEP <- "----------"
68             REP <- paste("\\1",SEP,"\\2",sep="")
69             r <- strsplit(gsub(FIND,REP,after,perl=TRUE),split=SEP)[[1]]
70             l <- strsplit(r,split="\n")
71             excode <- paste(l[[2]],"\n")
72             prefixes <- gsub("(\\s*).*","\\1",excode,perl=TRUE)[grep("\\w",excode)]
73             FIND <- prefixes[which.min(nchar(prefixes))]
74             list(examples=paste(sub(FIND,"",excode),collapse=""),
75                  value=decomment(l[[1]]))
76         }))         }))
77    
78  ### List of parser functions that operate on single objects. This list  ### List of parser functions that operate on single objects. This list

Legend:
Removed from v.95  
changed lines
  Added in v.96

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