[Roxygen-commits] r40 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 19 01:23:11 CEST 2008


Author: pcd
Date: 2008-06-19 01:23:11 +0200 (Thu, 19 Jun 2008)
New Revision: 40

Modified:
   pkg/R/parse.R
Log:
S3class; warning; fix value


Modified: pkg/R/parse.R
===================================================================
--- pkg/R/parse.R	2008-06-18 22:40:55 UTC (rev 39)
+++ pkg/R/parse.R	2008-06-18 23:23:11 UTC (rev 40)
@@ -31,9 +31,15 @@
 
 ## preref parsers
 
+parse.message <- function(key, message)
+  sprintf('@%s %s.', key, message)
+
 parse.error <- function(key, message)
-  stop(sprintf('@%s %s.', key, message))
+  stop(parse.message(key, message))
 
+parse.warning <- function(key, message)
+  warning(parse.message(key, message))
+
 parse.preref <- function(...) {
   list(unknown=paste(...))
 }
@@ -55,14 +61,16 @@
 parse.default <- function(key, ...)
   as.list(structure(args.to.string(...), names=key))
 
-## Possibly NA, for which the Roclets can do something more
+## Possibly NA; in which case, the Roclets can do something more
 ## sophisticated with the srcref.
 parse.export <- Curry(parse.default, key='export')
 
-parse.value <- function(key, ...)
-  ifelse(is.empty(...),
-         parse.error(key, 'requires a value'),
-         parse.default(key, ...))
+parse.value <- function(key, ...) {
+  if (is.empty(...))
+    parse.error(key, 'requires a value')
+  else
+    parse.default(key, ...)
+}
   
 parse.prototype <- Curry(parse.value, key='prototype')
 
@@ -96,10 +104,16 @@
 
 parse.param <- Curry(parse.name.description, key='param')
 
-## For S3 classes; single name only, and glean description from top
-## line of block?
-parse.class <- Curry(parse.name.description, key='class')
+parse.name <- function(key, name, ...) {
+  if (is.na(name))
+    parse.error(key, 'requires a name')
+  else if (Negate(is.empty)(...))
+    parse.warning(key, 'discards extra-nominal entries')
+  parse.default(key, name)
+}
 
+parse.S3class <- Curry(parse.name, key='S3class')
+
 parse.toggle <- function(key, ...)
   as.list(structure(T, names=key))
 



More information about the Roxygen-commits mailing list