[Roxygen-commits] r144 - in pkg: R sandbox

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Aug 2 09:21:28 CEST 2008


Author: pcd
Date: 2008-08-02 09:21:27 +0200 (Sat, 02 Aug 2008)
New Revision: 144

Modified:
   pkg/R/callgraph.R
   pkg/R/parse.R
   pkg/R/roclet.R
   pkg/sandbox/classGraph.R
Log:
sQuote wesen; supercalls with all.names (thank, Manuel); number parser?; export registration functions; fix lhs bug; export make.roclet; fix classGraph


Modified: pkg/R/callgraph.R
===================================================================
--- pkg/R/callgraph.R	2008-08-01 10:44:53 UTC (rev 143)
+++ pkg/R/callgraph.R	2008-08-02 07:21:27 UTC (rev 144)
@@ -41,8 +41,7 @@
       warning(sprintf(paste('Package(s) %s wouldn\'t load;',
                             'callgraphs might be incomplete.'),
                       do.call(Curry(paste, sep=', '),
-                              Map(Curry(sprintf, fmt='`%s\''),
-                                  dependencies[!successes]))))
+                              Map(sQuote, dependencies[!successes]))))
   }
   
   parse.default <- function(key, expression) NULL
@@ -150,10 +149,10 @@
   OUTFILE <- '%s-callgraph.pdf'
 
   graphviz <- function(subcalls) {
-    supercalls <- ls(subcalls)
+    supercalls <- ls(subcalls, all.names=TRUE)
     if (length(supercalls) < 1 || is.null(supercalls))
-      warning(sprintf('Omitting call-less call-graph for `%s\'.',
-                      name))
+      warning(sprintf('Omitting call-less call-graph for %s.',
+                      sQuote(name)))
     else {
       graph <- new('graphNEL',
                    nodes=unlist(Map(remove.edge.separators, supercalls)),
@@ -164,14 +163,14 @@
                                     remove.edge.separators(subsupercall),
                                     graph),
                    error=function(e)
-                   warning(sprintf('Unknown node %s', subsupercall)))
+                   warning(sprintf('Unknown node %s', sQuote(subsupercall))))
       ag <- agopenSimple(graph, 'roxygenize')
       graphDataDefaults(ag, 'ratio') <- PHI
       graphDataDefaults(ag, 'splines') <- 'true'
       nodeDataDefaults(ag, 'fontname') <- 'monospace'
       outfile <- file.path(dir, sprintf(OUTFILE, name))
       if (verbose)
-        cat(sprintf('Outputting call graph to %s\n', outfile))
+        cat(sprintf('Outputting call graph to %s\n', sQuote(outfile)))
       toFile(ag,
              layoutType='fdp',
              filename=outfile,

Modified: pkg/R/parse.R
===================================================================
--- pkg/R/parse.R	2008-08-01 10:44:53 UTC (rev 143)
+++ pkg/R/parse.R	2008-08-02 07:21:27 UTC (rev 144)
@@ -2,6 +2,7 @@
 #' @include functional.R
 #' @include string.R
 #' @include list.R
+#' @TODO number parser?
 roxygen()
 
 #' Sequence that distinguishes roxygen comment from normal comment.
@@ -66,6 +67,7 @@
 #' a function taking \code{key} and \code{expression}
 #' @return \code{NULL}
 #' @seealso \code{\link{register.parser}}
+#' @export
 register.srcref.parser <- Curry(register.parser,
                                 table=srcref.parsers)
 
@@ -83,6 +85,7 @@
 #' @param parser the parser to register
 #' @param \dots the keys upon which to register
 #' @return \code{NULL}
+#' @export
 register.preref.parsers <- Curry(register.parsers,
                                  table=preref.parsers)
 
@@ -90,6 +93,7 @@
 #' @param parser the parser to register
 #' @param \dots the keys upon which to register
 #' @return \code{NULL}
+#' @export
 register.srcref.parsers <- Curry(register.parsers,
                                  table=srcref.parsers)
 
@@ -137,6 +141,7 @@
 #' @param rest the expression to be parsed
 #' @return A list containing the key and expression (possibly
 #' null)
+#' @export
 parse.default <- function(key, rest)
   as.list(structure(rest, names=key))
 
@@ -161,6 +166,7 @@
 #' @param key the parsing key
 #' @param rest the expression to be parsed
 #' @return A list containing the key and value
+#' @export
 parse.value <- function(key, rest) {
   if (is.null.string(rest))
     parse.error(key, 'requires a value')
@@ -207,6 +213,7 @@
 #' @param rest the expression to be parsed
 #' @return A list containing the key, name and
 #' description
+#' @export
 parse.name.description <- function(key, rest) {
   name <- strcar(rest)
   rest <- strcdr(rest)
@@ -231,6 +238,7 @@
 #' @param key parsing key
 #' @param name the name to be parsed
 #' @return A list containing key and name
+#' @export
 parse.name <- function(key, name) {
   if (is.null.string(name))
     parse.error(key, 'requires a name')
@@ -474,7 +482,7 @@
     formals <- parse.formals(cdddr(expressions))
     append(assignee, formals)
   } else {
-    lhs <- as.character(cadr(expressions))
+    lhs <- cadr(as.character(expressions))
     parser.srcref(lhs)(lhs, cddr(expressions))
   }
 }
@@ -506,6 +514,7 @@
 #' Parse a source file containing roxygen directives.
 #' @param file string naming file to be parsed
 #' @return List containing parsed directives
+#' @export
 #' @callGraph
 #' @callGraphDepth 3
 parse.file <- function(file) {
@@ -522,6 +531,7 @@
 #' @param \dots files to be parsed
 #' @return List containing parsed directives
 #' @seealso \code{\link{parse.file}}
+#' @export
 parse.files <- function(...)
   Reduce(append, Map(parse.file, list(...)), NULL)
 

Modified: pkg/R/roclet.R
===================================================================
--- pkg/R/roclet.R	2008-08-01 10:44:53 UTC (rev 143)
+++ pkg/R/roclet.R	2008-08-02 07:21:27 UTC (rev 144)
@@ -22,7 +22,8 @@
 #' called before any file has been parsed
 #' @param post.files a callback function with no arguments;
 #' called after every file has been parsed
-make.roclet <- function(parse.default,
+#' @export
+make.roclet <- function(parse.default=NULL,
                         pre.parse=NULL,
                         post.parse=NULL,
                         pre.files=NULL,

Modified: pkg/sandbox/classGraph.R
===================================================================
--- pkg/sandbox/classGraph.R	2008-08-01 10:44:53 UTC (rev 143)
+++ pkg/sandbox/classGraph.R	2008-08-02 07:21:27 UTC (rev 144)
@@ -2,8 +2,6 @@
 
 require(roxygen)
 
-
-
 #' Exemplar class: the JAVA bicycle class.
 #' @classGraph
 setClass('Bicycle',
@@ -12,10 +10,7 @@
            speed='numeric',
            gear='numeric'))
 
-
-
-#source('../R/parse.R')
-### Roclet:
+## Register tag with the main parser
 register.preref.parser('classGraph', parse.toggle)
 
 make.classGraph.roclet <- function(package, dir='.') {
@@ -24,7 +19,6 @@
   
   if ( !require(classGraph) )
     stop('This roclet needs the ', sQuote('classGraph'), 'package!')
-
   
   ### Roclet parser:
   
@@ -32,18 +26,19 @@
   file <- NULL
   
   pre.parse <- function(partitum) {
-    if ( partitum$S4class != '' ) {
+    if ( !is.null(partitum$S4class) ) {
       class <<- partitum$S4class
       file <<- partitum$srcref$filename
     }
   }
 
+  ## parse.classGraph only called on @classGraph;
+  ## no need to check the key
   parse.classGraph <- function(key, value) {
-    if ( key == 'classGraph' )
-      if ( !is.null(class) )
-        create.callGraph()
-      else
-        warning('@classGraph set but no S4 class far and wide.')
+    if ( !is.null(class) )
+      create.callGraph()
+    else
+      warning('@classGraph set but no S4 class far and wide.')
   }
   
   post.parse <- function(partitum) {
@@ -51,13 +46,12 @@
     file <<- NULL
   }
 
-  roclet <- roxygen:::make.roclet(parse.classGraph,
-                                  pre.parse,
-                                  post.parse)
+  ## No default parser
+  roclet <- roxygen:::make.roclet(pre.parse=pre.parse,
+                                  post.parse=post.parse)
 
-  roclet$register.default.parsers('classGraph')
+  roclet$register.parser('classGraph', parse.classGraph)
 
-
   ### Action:
 
   create.callGraph <- function() {



More information about the Roxygen-commits mailing list