[Roxygen-commits] r50 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jul 19 23:04:55 CEST 2008


Author: pcd
Date: 2008-07-19 23:04:55 +0200 (Sat, 19 Jul 2008)
New Revision: 50

Modified:
   pkg/R/Rd.R
   pkg/R/parse.R
Log:
pre-str{car,cdr}


Modified: pkg/R/Rd.R
===================================================================
--- pkg/R/Rd.R	2008-07-19 21:04:34 UTC (rev 49)
+++ pkg/R/Rd.R	2008-07-19 21:04:55 UTC (rev 50)
@@ -1,3 +1,4 @@
+#' @include list.R
 Rd <- function(partita) {
   relevators <- c('name',
                   'aliases',
@@ -47,6 +48,16 @@
 
   parse.aliases <- Curry(parse.split, key='alias')
 
+  parse.description <- function(expressions) {
+    print(expressions)
+    paragraphs <- strsplit(expressions, '\n\n', fixed=T)
+    description <- car(paragraphs)
+    details <- do.call(paste, c(cdr(paragraphs), sep='\n\n'))
+    parse.default('description', description)
+    if (Negate(is.nil)(details))
+      parse.default('details', details)
+  }
+
   parse.noop <- function(expression) NULL
 
   parsers <- list(name=parse.name,
@@ -60,7 +71,8 @@
                   examples=parse.examples,
                   concept=parse.concept,
                   aliases=parse.aliases,
-                  keywords=parse.keywords)
+                  keywords=parse.keywords,
+                  description=parse.description)
 
   parser <- function(key)
     if (is.null(f <- parsers[[key]])) parse.noop else f

Modified: pkg/R/parse.R
===================================================================
--- pkg/R/parse.R	2008-07-19 21:04:34 UTC (rev 49)
+++ pkg/R/parse.R	2008-07-19 21:04:55 UTC (rev 50)
@@ -1,18 +1,9 @@
+#' @include string.R list.R
 LINE.DELIMITER <- '#\' '
 TAG.DELIMITER <- '@'
-SPACE <- '([[:space:]]|\n)'
 
-trim.left <- function(string)
-  gsub(sprintf('^%s+', SPACE), '', string)
-
-trim.right <- function(string)
-  gsub(sprintf('%s+$', SPACE), '', string)
-
-trim <- function(string)
-  Compose(trim.left, trim.right)(string)
-
 paste.list <- function(list) {
-  do.call(paste, c(list, sep=" \n"))
+  do.call(paste, c(list, sep="\n"))
 }
 
 #' Comment blocks (possibly null) that precede a file's expressions.
@@ -47,7 +38,7 @@
   warning(parse.message(key, message))
 
 parse.element <- function(element) {
-  tokens <- car(strsplit(element, ' ', fixed=T))
+  tokens <- car(strsplit(element, SPACE))
   parser <- parser.preref(car(tokens))
   do.call(parser, as.list(cdr(tokens)))
 }
@@ -211,10 +202,12 @@
     elements <- Map(trim, car(strsplit(joined.lines, TAG.DELIMITER, fixed=T)))
 ###     elements <- car(strsplit(joined.lines, TAG.DELIMITER, fixed=T))
 ###     print(str(elements))
+    description <- car(elements)
     parsed.elements <- Reduce(function(parsed, element)
                               append(parsed, parse.element(element)),
                               cdr(elements),
-                              parse.description(car(elements)))
+                              if (is.null.string(description)) NULL
+                              else parse.description(description))
   }
 } 
 



More information about the Roxygen-commits mailing list