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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 24 06:36:41 CEST 2008


Author: pcd
Date: 2008-07-24 06:36:41 +0200 (Thu, 24 Jul 2008)
New Revision: 80

Modified:
   pkg/R/Rd.R
   pkg/R/namespace.R
   pkg/R/parse.R
   pkg/R/roclet.R
   pkg/sandbox/example-S3-mcpi.R
Log:
preliminary guess for empty @export


Modified: pkg/R/Rd.R
===================================================================
--- pkg/R/Rd.R	2008-07-23 22:24:19 UTC (rev 79)
+++ pkg/R/Rd.R	2008-07-24 04:36:41 UTC (rev 80)
@@ -36,12 +36,6 @@
   parse.expression <- function(key, ...)
     cat(Rd.expression(key, c(...)))
 
-  #' Find the first non-null argument.
-  #' @param \dots the arguments
-  #' @return The first non-null argument
-  first.non.null <- function(...)
-    append(NULL, c(...))[[1]]
-
   #' Reconstruct the \name directive from amongst
   #' \code{@@name}, \code{@@setMethod}, \code{@@setClass},
   #' \code{@@setGeneric}, \code{@@assignee}, etc.

Modified: pkg/R/namespace.R
===================================================================
--- pkg/R/namespace.R	2008-07-23 22:24:19 UTC (rev 79)
+++ pkg/R/namespace.R	2008-07-24 04:36:41 UTC (rev 80)
@@ -14,17 +14,52 @@
   parse.directive <- function(proc, parms)
     cat(sprintf('%s(%s)\n', proc, strmap(Identity, ', ', parms)))
   
-  roclet <- make.roclet(parse.directive)
+  exportee <- NULL
 
-  roclet$register.parser('exportClass',
-                         function(proc, parms)
-                         parse.directive('exportClasses', parms))
-  roclet$register.parser('exportMethod',
-                         function(proc, parms)
-                         parse.directive('exportMethods', parms))
+  pre.parse <- function(partitum)
+    exportee <<- list(name=partitum$name,
+                      assignee=partitum$assignee,
+                      S4method=partitum$S4method,
+                      S4generic=partitum$S4method,
+                      S4class=partitum$S4class)
 
-  roclet$register.default.parsers('export',
-                                  'exportPattern',
+  roclet <- make.roclet(parse.directive,
+                        pre.parse)
+
+  parse.exportClass <- function(proc, parms)
+    parse.directive('exportClasses', parms)
+
+  roclet$register.parser('exportClass', parse.exportClass)
+
+  parse.exportMethod <- function(proc, parms)
+    parse.directive('exportMethods', parms)
+
+  roclet$register.parser('exportMethod', parse.exportMethod)
+
+  parse.export <- function(proc, parms) {
+    if (is.null.string(parms)) {
+      if (!is.null(exportee$S4method))
+        parse.exportMethod(exportee$S4method)
+      else if (!is.null(exportee$S4class))
+        parse.exportClass(exportee$S4class)
+      else if (!is.null(exportee$S4method))
+        parse.exportMethod(exportee$S4method)
+      else {
+        exportee <- first.non.null(exportee$name,
+                                   exportee$assignee)
+        if (is.null(exportee))
+          warning('Empty export directive')
+        else
+          parse.directive('export', exportee)
+      }
+    }
+  }
+
+  roclet$register
+
+  roclet$register.parser('export', parse.export)
+
+  roclet$register.default.parsers('exportPattern',
                                   'S3method',
                                   'import',
                                   'importFrom',

Modified: pkg/R/parse.R
===================================================================
--- pkg/R/parse.R	2008-07-23 22:24:19 UTC (rev 79)
+++ pkg/R/parse.R	2008-07-24 04:36:41 UTC (rev 80)
@@ -359,8 +359,8 @@
       member <- tryCatch(expression[[i]], error=function(e) NULL)
       if (!is.null(member) && !identical(member, expression)) {
         proc(member)
-        if (typeof(member) != 'pairlist')
-          preorder.walk.expression(proc, member)
+        try(preorder.walk.expression(proc, member),
+            silent=TRUE)
       }
     }
 }

Modified: pkg/R/roclet.R
===================================================================
--- pkg/R/roclet.R	2008-07-23 22:24:19 UTC (rev 79)
+++ pkg/R/roclet.R	2008-07-24 04:36:41 UTC (rev 80)
@@ -97,3 +97,10 @@
 #' @return NULL
 assign.parent <- function(var, value, env)
   assign(var, value, envir=parent.env(env))
+
+#' Find the first non-null argument.
+#' @param \dots the arguments
+#' @return The first non-null argument
+first.non.null <- function(...)
+  append(NULL, c(...))[[1]]
+

Modified: pkg/sandbox/example-S3-mcpi.R
===================================================================
--- pkg/sandbox/example-S3-mcpi.R	2008-07-23 22:24:19 UTC (rev 79)
+++ pkg/sandbox/example-S3-mcpi.R	2008-07-24 04:36:41 UTC (rev 80)
@@ -15,7 +15,7 @@
 #' @returnType mcpi
 #' @return a list containing the approximated
 #'         PI value and the throws
-#' @export mcpiX
+#' @export
 mcpiX <- function(trials) {
 
   throws <- matrix(NA, nrow=trials,



More information about the Roxygen-commits mailing list