[Roxygen-commits] r134 - in pkg: . R sandbox tests/runit

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jul 30 06:49:45 CEST 2008


Author: pcd
Date: 2008-07-30 06:49:45 +0200 (Wed, 30 Jul 2008)
New Revision: 134

Modified:
   pkg/R/Rd.R
   pkg/R/description.R
   pkg/R/parse.R
   pkg/README
   pkg/sandbox/Rd.R
   pkg/sandbox/description.R
   pkg/tests/runit/runit.Rd.R
   pkg/tests/runit/runit.collate.R
Log:
@TODO; description.dependencies in preparation for callgraph


Modified: pkg/R/Rd.R
===================================================================
--- pkg/R/Rd.R	2008-07-30 04:49:28 UTC (rev 133)
+++ pkg/R/Rd.R	2008-07-30 04:49:45 UTC (rev 134)
@@ -29,6 +29,7 @@
 #' \code{@@return} \tab \code{\\value}\cr
 #' \code{@@seealso} \tab \code{\\seealso}\cr
 #' \code{@@title} \tab \code{\\title}\cr
+#' \code{@@todo} \tab \emph{n/a}\cr
 #' \code{@@usage} \tab \code{\\usage}\cr
 #' }
 #'
@@ -74,6 +75,7 @@
 #'                       In the absence of a description, the title becomes
 #'                       the \code{@@name} or assignee; lastly, it can be
 #'                       overridden with \code{@@title}.}
+#' \item{\code{@@todo}}{Note to developers to get off their asses.}
 #' \item{\code{@@usage}}{A default usage is construed from a function's formals,
 #'                       but can be overridden with \code{@@usage} (e.g. in the case
 #'                       of multiple functions in one Rd unit).}
@@ -422,5 +424,10 @@
 
   roclet$register.parser('example', parse.example)
 
+  parse.todo <- function(key, value)
+    parse.expression('section', 'TODO', value)
+
+  roclet$register.parser('TODO', parse.todo)
+
   roclet
 }

Modified: pkg/R/description.R
===================================================================
--- pkg/R/description.R	2008-07-30 04:49:28 UTC (rev 133)
+++ pkg/R/description.R	2008-07-30 04:49:45 UTC (rev 134)
@@ -67,7 +67,7 @@
 #' @return \code{NULL}
 cat.description <- function(field, value, file='')
   cat(strwrap(sprintf('%s: %s', field, value),
-              exdent=2),
+              exdent=4),
       sep='\n',
       file=file,
       append=TRUE)
@@ -99,6 +99,9 @@
   parsers <- new.env(parent=emptyenv())
   parser$register.parser <- function(field, parser)
     parsers[[field]] <- parser
+  parser$register.parsers <- function(registrate, ...)
+    for (field in c(...))
+      parser$register.parser(field, registrate)
   parser$parse <- function(parsed.fields) {
     field.values <- function(parsed.fields)
       zip.list(names(parsed.fields),
@@ -117,3 +120,27 @@
   }
   parser
 }
+
+#' Gather a \file{DESCRIPTION}'s dependencies from the
+#' \code{Package}, \code{Depends}, \code{Imports}, \code{Suggests},
+#' and \code{Enhances} fields.
+#' @param description.file the \file{DESCRIPTION} to parse
+#' @return A list of dependencies
+#' @TODO Test this!
+description.dependencies <- function(description.file) {
+  dependencies <- NULL
+  split.dependencies <- function(parsed.fields)
+    strsplit(dependencies, split='[[:space:]]+')
+  parser <- make.description.parser(noop.description,
+                                    post.parse=split.dependencies)
+  augment.dependencies <- function(field, value)
+    dependencies <<- paste(value, dependencies)
+  
+  parser$register.parsers(augment.dependencies,
+                          'Package',
+                          'Depends',
+                          'Imports',
+                          'Suggests',
+                          'Enhances')
+  parser$parse(parse.description.file(description.file))
+}

Modified: pkg/R/parse.R
===================================================================
--- pkg/R/parse.R	2008-07-30 04:49:28 UTC (rev 133)
+++ pkg/R/parse.R	2008-07-30 04:49:45 UTC (rev 134)
@@ -197,7 +197,8 @@
                         'return',
                         'author',
                         'include',
-                        'callGraphDepth')
+                        'callGraphDepth',
+                        'TODO')
 
 #' Parse an element containing a mandatory name
 #' and description (such as @@param).

Modified: pkg/README
===================================================================
--- pkg/README	2008-07-30 04:49:28 UTC (rev 133)
+++ pkg/README	2008-07-30 04:49:45 UTC (rev 134)
@@ -55,5 +55,7 @@
 
 * Nameless Rd entries are written to standard out with no warning.
 
+* @deprecated?
+
 -----------
 * Hail, Hephaistos! Grant skill and weal.

Modified: pkg/sandbox/Rd.R
===================================================================
--- pkg/sandbox/Rd.R	2008-07-30 04:49:28 UTC (rev 133)
+++ pkg/sandbox/Rd.R	2008-07-30 04:49:45 UTC (rev 134)
@@ -6,7 +6,6 @@
 source('../R/roclet.R')
 source('../R/Rd.R')
 
-## FILES <- list('example-Rd-nlm.R')
 FILES <- list('../R/Rd.R')
 
 argv <- commandArgs(trailingOnly=T)

Modified: pkg/sandbox/description.R
===================================================================
--- pkg/sandbox/description.R	2008-07-30 04:49:28 UTC (rev 133)
+++ pkg/sandbox/description.R	2008-07-30 04:49:45 UTC (rev 134)
@@ -1,3 +1,4 @@
+source('../R/roxygen.R')
 source('../R/list.R')
 source('../R/functional.R')
 source('../R/string.R')
@@ -4,4 +5,5 @@
 source('../R/description.R')
 
 parser <- make.description.parser()
-parser$parse(parse.description.file('../DESCRIPTION'))
+## parser$parse(parse.description.file('../DESCRIPTION'))
+description.dependencies('../DESCRIPTION')

Modified: pkg/tests/runit/runit.Rd.R
===================================================================
--- pkg/tests/runit/runit.Rd.R	2008-07-30 04:49:28 UTC (rev 133)
+++ pkg/tests/runit/runit.Rd.R	2008-07-30 04:49:45 UTC (rev 134)
@@ -138,3 +138,8 @@
                     '\\title{Whether a number is odd...}',
                     '\\usage{is.odd(a)}',
                     '\\description{Whether a number is odd}'))
+
+test.todo <- function()
+  check.Rd.output("#' @TODO test this
+                   roxygen()",
+                  output=c('\\section{TODO}{test this}'))

Modified: pkg/tests/runit/runit.collate.R
===================================================================
--- pkg/tests/runit/runit.collate.R	2008-07-30 04:49:28 UTC (rev 133)
+++ pkg/tests/runit/runit.collate.R	2008-07-30 04:49:45 UTC (rev 134)
@@ -12,8 +12,9 @@
                                            'runit/collate/watch.R'))
   checkEquals(collation,
               c("Collate: 'runit/collate/shirt.R' 'runit/collate/undershorts.R'",
-                "  'runit/collate/pants.R' 'runit/collate/belt.R' 'runit/collate/tie.R'",
-                "  'runit/collate/jacket.R' 'runit/collate/socks.R'",
-                "  'runit/collate/shoes.R' 'runit/collate/watch.R'"),
+                "    'runit/collate/pants.R' 'runit/collate/belt.R'",
+                "    'runit/collate/tie.R' 'runit/collate/jacket.R'",
+                "    'runit/collate/socks.R' 'runit/collate/shoes.R'",
+                "    'runit/collate/watch.R'"),
               msg=collation)
 }



More information about the Roxygen-commits mailing list