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 104, Tue May 18 16:35:08 2010 UTC revision 105, Tue May 18 17:32:43 2010 UTC
# Line 637  Line 637 
637    }    }
638    invisible(docs)    invisible(docs)
639  }  }
640    
641    extract.docs.code <- function
642    ### Write code to a file and parse it to r objs, then run all the
643    ### parsers and return the documentation list.
644    (code,
645    ### Character vector of code lines.
646     parsers,
647    ### List of Parser Functions.
648     verbose=TRUE,
649    ### Echo names of Parser Functions?
650     ...
651    ### Additional arguments to pass to Parser Functions.
652     ){
653      code.file <- tempfile()
654      writeLines(code,code.file)
655      e <- new.env()
656      old <- options(keep.source.pkgs=TRUE)
657      tryCatch(suppressWarnings(sys.source(code.file,e)),error=function(e){
658        stop("source ",code.file," failed with error:\n",e)
659      })
660      options(old)
661      objs <- sapply(ls(e),get,e,simplify=FALSE)
662    
663      ## apply parsers in sequence to code and objs
664      docs <- list()
665      for(i in seq_along(parsers)){
666        N <- names(parsers[i])
667        if(verbose){
668          if(is.character(N) && N!=""){
669            cat(N," ",sep="")
670          }else cat('. ')
671        }
672        p <- parsers[[i]]
673        ## This is the argument list that each parser receives:
674        L <- p(code=code,objs=objs,docs=docs,...)
675        docs <- combine(docs,L)
676      }
677      if(verbose)cat("\n")
678      docs
679    ### A list of extracted documentation from code.
680    }

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

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