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 186, Fri Jan 14 18:43:36 2011 UTC revision 191, Thu Feb 17 14:09:43 2011 UTC
# Line 184  Line 184 
184    res    res
185  },ex=function(){  },ex=function(){
186  test <- function  test <- function
187  ### the desc  ### the description
188  (x,  (x,
189  ### the first argument  ### the first argument
190   y ##<< another argument   y ##<< another argument
# Line 282  Line 282 
282          chunk.sep <- "\n\n"          chunk.sep <- "\n\n"
283        }        }
284        chunk.res <- NULL        chunk.res <- NULL
285        if ( 0 == length(grep("^\\s*$",payload,perl=TRUE)) )        if ( !grepl("^\\s*$",payload,perl=TRUE) )
286          chunk.res <-          chunk.res <-
287            if ( is.null(res[[field]]) ) payload            if ( is.null(res[[field]]) ) payload
288            else paste(res[[field]], payload, sep=chunk.sep)            else paste(res[[field]], payload, sep=chunk.sep)
# Line 290  Line 290 
290      }      }
291    while ( k <= length(src) ){    while ( k <= length(src) ){
292      line <- src[k]      line <- src[k]
293      if ( 0 < length(grep(extra.regexp,line,perl=TRUE) ) ){      if ( grepl(extra.regexp,line,perl=TRUE) ){
294        ## we have a new extra chunk - first get field name and any payload        ## we have a new extra chunk - first get field name and any payload
295        new.field <- gsub(extra.regexp,"\\1",line,perl=TRUE)        new.field <- gsub(extra.regexp,"\\1",line,perl=TRUE)
296        new.contents <- gsub(extra.regexp,"\\2",line,perl=TRUE)        new.contents <- gsub(extra.regexp,"\\2",line,perl=TRUE)
# Line 365  Line 365 
365            first.describe <- TRUE;            first.describe <- TRUE;
366          }          }
367        }        }
368      } else if ( in.chunk && 0<length(grep(cont.re,line,perl=TRUE)) ){      } else if ( in.chunk && grepl(cont.re,line,perl=TRUE) ){
369        ## append this line to current chunk        ## append this line to current chunk
370        if ( 0 == length(grep(prefix,line,perl=TRUE)) ){        if ( !grepl(prefix,line,perl=TRUE) ){
371          ##describe<< Any lines with "\code{### }" at the left hand          ##describe<< Any lines with "\code{### }" at the left hand
372          ## margin within the included chunks are handled separately,          ## margin within the included chunks are handled separately,
373          ## so if they appear in the documentation they will appear          ## so if they appear in the documentation they will appear
# Line 380  Line 380 
380            payload <- stripped            payload <- stripped
381          }          }
382        }        }
383      } else if ( 0 < length(grep(arg.pat,line,perl=TRUE)) ){      } else if ( grepl(arg.pat,line,perl=TRUE) ){
384        not.describe <- (0==in.describe && !first.describe)        not.describe <- (0==in.describe && !first.describe)
385        if ( in.chunk && not.describe){        if ( in.chunk && not.describe){
386          res[[cur.field]] <- end.chunk(cur.field,payload)          res[[cur.field]] <- end.chunk(cur.field,payload)
# Line 450  Line 450 
450         examples.after.return=examples.after.return,         examples.after.return=examples.after.return,
451         extract.xxx.chunks=extract.xxx.chunks,         extract.xxx.chunks=extract.xxx.chunks,
452         ## title from first line of function def         ## title from first line of function def
453         title.from.firstline=function(src,name,code,...){         title.from.firstline=function(src,...){
454           if(length(grep("#",src[1]))){           if(length(src) && grepl("#",src[1])){
455             list(title=gsub("[^#]*#\\s*(.*)","\\1",src[1],perl=TRUE))             list(title=gsub("[^#]*#\\s*(.*)","\\1",src[1],perl=TRUE))
456           } else list()           } else list()
457         },         },
# Line 573  Line 573 
573                    pattern <- "^([^\\.]+)\\.(.*)$"                    pattern <- "^([^\\.]+)\\.(.*)$"
574            doc$s3method=c(m1 <- gsub(pattern,"\\1",on,perl=TRUE),            doc$s3method=c(m1 <- gsub(pattern,"\\1",on,perl=TRUE),
575                m2 <- gsub(pattern,"\\2",on,perl=TRUE))                m2 <- gsub(pattern,"\\2",on,perl=TRUE))
576            if ( 0 < length(grep("\\W",m1,perl=TRUE)) ){            if ( grepl("\\W",m1,perl=TRUE) ){
577                            m1 <- paste("`",m1,"`",sep="")                            m1 <- paste("`",m1,"`",sep="")
578            }            }
579            cat("S3method(",m1,",",m2,")\n",sep="")            cat("S3method(",m1,",",m2,")\n",sep="")
# Line 597  Line 597 
597        NULL        NULL
598      } else if(0 == length(res) && "function" %in% class(o)      } else if(0 == length(res) && "function" %in% class(o)
599                && 1 == length(osource <- attr(o,"source"))                && 1 == length(osource <- attr(o,"source"))
600                && 1 == length(grep(paste("UseMethod(",on,")",sep="\""),osource))                && grepl(paste("UseMethod(",on,")",sep="\""),osource)
601                ){                ){
602        ## phew - this should only pick up R.oo S3 generic definitions like:        ## phew - this should only pick up R.oo S3 generic definitions like:
603        ## attr(*, "source")= chr "function(...) UseMethod(\"select\")"        ## attr(*, "source")= chr "function(...) UseMethod(\"select\")"
# Line 710  Line 710 
710      ## "prefix" lines will be used instead.      ## "prefix" lines will be used instead.
711      default.description <- NULL      default.description <- NULL
712      while ( start > last.end+1      while ( start > last.end+1
713             && 1 == length(grep(prefix,code[start-1],perl=TRUE)) ){             && grepl(prefix,code[start-1],perl=TRUE) ){
714        start <- start-1        start <- start-1
715      }      }
716      if ( start < chunks[[k]][1] ){      if ( start < chunks[[k]][1] ){
# Line 737  Line 737 
737        ## If the function definition is not embedded within the call, then        ## If the function definition is not embedded within the call, then
738        ## the parent is that function. Test whether the the third value        ## the parent is that function. Test whether the the third value
739        ## looks like a name and add it to parents if so.        ## looks like a name and add it to parents if so.
740        if ( 1 == length(grep("^[\\._\\w]+$",chars[3],perl=TRUE)) ){        if ( grepl("^[\\._\\w]+$",chars[3],perl=TRUE) ){
741          parent <- chars[3]          parent <- chars[3]
742        }        }
743        res[[object.name]] <- new("DocLink",name=object.name,        res[[object.name]] <- new("DocLink",name=object.name,
# Line 769  Line 769 
769        ## If the function definition is not embedded within the call, then        ## If the function definition is not embedded within the call, then
770        ## the parent is that function. Test whether the the fourth value        ## the parent is that function. Test whether the the fourth value
771        ## looks like a name and add it to parents if so.        ## looks like a name and add it to parents if so.
772        if ( 1 == length(grep("^[\\._\\w]+$",chars[4],perl=TRUE)) ){        if ( grepl("^[\\._\\w]+$",chars[4],perl=TRUE) ){
773          parent <- c(chars[4],parent)          parent <- c(chars[4],parent)
774        }        }
775        res[[object.name]] <- new("DocLink",name=object.name,        res[[object.name]] <- new("DocLink",name=object.name,

Legend:
Removed from v.186  
changed lines
  Added in v.191

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