[Roxygen-commits] r259 - in pkg: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 23 11:21:00 CET 2011


Author: pcd
Date: 2011-03-23 11:21:00 +0100 (Wed, 23 Mar 2011)
New Revision: 259

Modified:
   pkg/R/Rd.R
   pkg/R/Rd2.R
   pkg/R/parseS4.R
   pkg/TODO
Log:
move the srcref and preref registrations into the roclet, so they play nicely with others; TODO: chain of roclets on tags

Modified: pkg/R/Rd.R
===================================================================
--- pkg/R/Rd.R	2011-03-21 09:54:27 UTC (rev 258)
+++ pkg/R/Rd.R	2011-03-23 10:21:00 UTC (rev 259)
@@ -4,44 +4,6 @@
 #' @include parse.R
 roxygen()
 
-register.preref.parsers(parse.value,
-                        'name',
-                        'aliases',
-                        'title',
-                        'usage',
-                        'references',
-                        'concept',
-                        'note',
-                        'seealso',
-                        'example',
-                        'examples',
-                        'keywords',
-                        'return',
-                        'author',
-                        'TODO',
-                        'format',
-                        'source')
-
-register.preref.parsers(parse.name.description,
-                        'param',
-                        'method')
-
-register.preref.parsers(parse.name,
-                        'docType')
-
-register.srcref.parser('setClass',
-                       function(pivot, expression)
-                       list(S4class=car(expression)))
-
-register.srcref.parser('setGeneric',
-                       function(pivot, expression)
-                       list(S4generic=car(expression)))
-
-register.srcref.parser('setMethod',
-                       function(pivot, expression)
-                       list(S4method=car(expression),
-                            signature=cadr(expression)))
-
 ##' Substitutions of questionable characters with a hacker-joke to
 ##' boot.
 substitutions=c(
@@ -215,6 +177,44 @@
 #' make.Rd.roclet
 make.Rd.roclet <- function(subdir=NULL,
                            verbose=TRUE) {
+  register.preref.parsers(parse.value,
+                          'name',
+                          'aliases',
+                          'title',
+                          'usage',
+                          'references',
+                          'concept',
+                          'note',
+                          'seealso',
+                          'example',
+                          'examples',
+                          'keywords',
+                          'return',
+                          'author',
+                          'TODO',
+                          'format',
+                          'source')
+
+  register.preref.parsers(parse.name.description,
+                          'param',
+                          'method')
+
+  register.preref.parsers(parse.name,
+                          'docType')
+
+  register.srcref.parser('setClass',
+                         function(pivot, expression)
+                         list(S4class=car(expression)))
+
+  register.srcref.parser('setGeneric',
+                         function(pivot, expression)
+                         list(S4generic=car(expression)))
+
+  register.srcref.parser('setMethod',
+                         function(pivot, expression)
+                         list(S4method=car(expression),
+                              signature=cadr(expression)))
+
   #' Translate a key and expressions into an Rd expression;
   #' multiple expressions take their own braces.
   #' @param key the expression's key
@@ -488,13 +488,15 @@
   #' in an Rd-readable list (with \code{\\item}s, etc.).
   #' @param name.param name-param pair
   #' @return A list of Rd-readable expressions
-  parse.params <- function()
+  parse.params <- function() {
+    debug(params=params)
     Reduce.paste(function(name.param)
                  Rd.expression('item',
                      car(name.param),
                      cadr(name.param)),
                  params,
                  '')
+  }
 
   #' Paste and label the Rd-readable expressions
   #' returned by \code{parse.params}.

Modified: pkg/R/Rd2.R
===================================================================
--- pkg/R/Rd2.R	2011-03-21 09:54:27 UTC (rev 258)
+++ pkg/R/Rd2.R	2011-03-23 10:21:00 UTC (rev 259)
@@ -8,53 +8,6 @@
 #' @include Rdmerge.R
 roxygen()
 
-register.preref.parsers(parse.default,
-                        'nord')
-
-register.preref.parsers(parse.value,
-                        'name',
-                        'aliases',
-                        'title',
-                        'usage',
-                        'references',
-                        'concept',
-                        'note',
-                        'seealso',
-                        'example',
-                        'examples',
-                        'keywords',
-                        'return',
-                        'author',
-                        'TODO',
-                        'format',
-                        'source',
-                        'rdname')
-
-register.preref.parsers(parse.name.description,
-                        'param',
-                        'method',
-                        'slot')
-
-register.preref.parsers(parse.name,
-                        'docType')
-
-register.srcref.parser('setClass',
-                       function(pivot, expression)
-                       list(S4class=car(expression),
-                            S4formals=parseS4.class(cdr(expression))))
-
-register.srcref.parser('setGeneric',
-                       function(pivot, expression)
-                       list(S4generic=car(expression)))
-
-register.srcref.parser('setMethod',
-                       function(pivot, expression) {
-                         S4formals <- parseS4.method(cdr(expression))
-                         list(S4method=car(expression),
-                              S4formals=S4formals,
-                              formals=S4formals$definition)
-                       })
-
 #' New implementation of the Rd roclet; same functionality as the original
 #' implementation plus basic S4 handling.
 #'
@@ -84,6 +37,53 @@
                             exportonly=FALSE,
                             documentedonly=TRUE) {
 
+  register.preref.parsers(parse.default,
+                          'nord')
+
+  register.preref.parsers(parse.value,
+                          'name',
+                          'aliases',
+                          'title',
+                          'usage',
+                          'references',
+                          'concept',
+                          'note',
+                          'seealso',
+                          'example',
+                          'examples',
+                          'keywords',
+                          'return',
+                          'author',
+                          'TODO',
+                          'format',
+                          'source',
+                          'rdname')
+
+  register.preref.parsers(parse.name.description,
+                          'param',
+                          'method',
+                          'slot')
+
+  register.preref.parsers(parse.name,
+                          'docType')
+
+  register.srcref.parser('setClass',
+                         function(pivot, expression)
+                         list(S4class=car(expression),
+                              S4formals=parseS4.class(cdr(expression))))
+
+  register.srcref.parser('setGeneric',
+                         function(pivot, expression)
+                         list(S4generic=car(expression)))
+
+  register.srcref.parser('setMethod',
+                         function(pivot, expression) {
+                           S4formals <- parseS4.method(cdr(expression))
+                           list(S4method=car(expression),
+                                S4formals=S4formals,
+                                formals=S4formals$definition)
+                         })
+
   require(tools)
   
   rdtank <- make.Rdtank()

Modified: pkg/R/parseS4.R
===================================================================
--- pkg/R/parseS4.R	2011-03-21 09:54:27 UTC (rev 258)
+++ pkg/R/parseS4.R	2011-03-23 10:21:00 UTC (rev 259)
@@ -31,7 +31,6 @@
   # Heuristic that the first unnamed language
   # object is the definition:
   def <- which(sapply(expression, is.call) & names(expression) == '')[1]
-
   formals <- list(definition=
                   parse.formals(expression[c(def, def+1)])[[1]])
 

Modified: pkg/TODO
===================================================================
--- pkg/TODO	2011-03-21 09:54:27 UTC (rev 258)
+++ pkg/TODO	2011-03-23 10:21:00 UTC (rev 259)
@@ -1,4 +1,11 @@
 # -*- mode: org; -*-
+* TODO named signature arg in =setMethod=
+  #+BEGIN_SRC R :noweb yes :tangle test-named-signature.R
+    <<preamble>>
+    
+    capture.output(make.Rd.roclet()$parse('sandbox/example-S4-person.R'))
+    
+  #+END_SRC
 * TODO how to convert an existing package at top of vignette
 * TODO distinguish between =arg=NULL= and no default arg
 * DONE handling double-quotes in default args



More information about the Roxygen-commits mailing list