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 162, Wed Nov 10 09:18:20 2010 UTC revision 163, Tue Nov 16 12:06:29 2010 UTC
# Line 69  Line 69 
69  ### For each function in the package, do something.  ### For each function in the package, do something.
70  forfun <- function(FUN)forall(FUN,is.function)  forfun <- function(FUN)forall(FUN,is.function)
71    
72    kill.prefix.whitespace <- function
73    ### Figure out what the whitespace preceding the example code is, and
74    ### then delete that from every line.
75    (ex
76    ### character vector of example code lines.
77     ){
78      tlines <- gsub("\\s*","",ex)
79      ##tlines <- gsub("#.*","",tlines)
80      prefixes <- unique(gsub("\\S.*","",ex[tlines!=""]))
81      FIND <- prefixes[which.min(nchar(prefixes))]
82      ## Eliminate leading tabulations or 2/4 spaces
83      sub(FIND, "", ex)
84    ### Character vector of code lines with preceding whitespace removed.
85    }
86    
87  examples.after.return <- function  examples.after.return <- function
88  ### Get examples from inline definitions after return()  ### Get examples from inline definitions after return()
89  ### PhG: this does not work well! Think of these situations:  ### PhG: this does not work well! Think of these situations:
# Line 113  Line 128 
128    ## Possibly eliminate a #}}} tag    ## Possibly eliminate a #}}} tag
129    ex <- ex[!grepl("#}}}", ex)]    ex <- ex[!grepl("#}}}", ex)]
130    ## Eliminate leading tabulations or four spaces    ## Eliminate leading tabulations or four spaces
131    prefixes <- gsub("(\\s*).*","\\1",ex,perl=TRUE)[grep("\\w",ex)]    ex <- kill.prefix.whitespace(ex)
   FIND <- prefixes[which.min(nchar(prefixes))]  
   ex <- sub(FIND,"",ex)  
132    ## Add an empty line before and after example    ## Add an empty line before and after example
133    ex <- c("", ex, "")    ex <- c("", ex, "")
134    ## Return examples and value    ## Return examples and value
# Line 474  Line 487 
487               }               }
488               ## Eliminate leading and trailing code               ## Eliminate leading and trailing code
489               ex <- ex[-c(1, length(ex))]               ex <- ex[-c(1, length(ex))]
490               ## Eliminate leading tabulations or 2/4 spaces               ## all the prefixes
491               ex <- sub("^\t|    |  ", "", ex)               ex <- kill.prefix.whitespace(ex)
492               ## Add an empty line before and after example               ## Add an empty line before and after example
493               ex <- c("", ex, "")               ex <- c("", ex, "")
494             }             }

Legend:
Removed from v.162  
changed lines
  Added in v.163

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