[Roxygen-commits] r104 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Jul 27 06:44:24 CEST 2008
Author: pcd
Date: 2008-07-27 06:44:24 +0200 (Sun, 27 Jul 2008)
New Revision: 104
Modified:
pkg/R/collate.R
pkg/R/roxygenize.R
Log:
parse$dir in collate
Modified: pkg/R/collate.R
===================================================================
--- pkg/R/collate.R 2008-07-27 04:29:31 UTC (rev 103)
+++ pkg/R/collate.R 2008-07-27 04:44:24 UTC (rev 104)
@@ -4,14 +4,15 @@
roxygen()
#' Make collate roclet which parses the given files; topologically
-#' sorting \code{@@include}s and writing a \code{Collate:} directive to
+#' sorting \code{@@include}s, and either merging the \code{Collate:}
+#' directive with a pre-existing \file{DESCRIPTION} or writing to
#' standard out.
#'
#' Each \code{@@include} tag should specify the filename of one intrapackage
#' dependency; multiple \code{@@include} tags may be given.
#'
#' Contains the member function \code{parse} which parses an arbitrary number
-#' of files.
+#' of files, and \code{parse.dir} which recursively parses a directory tree.
#'
#' @param merge.file \file{DESCRIPTION} file with which to merge directive;
#' or \code{NULL} for none
@@ -22,13 +23,15 @@
#' @return Rd roclet
#' @seealso \code{\link{make.roclet}}
#' @examples
-#' #' An example source file, example.R
-#' #' @@include roxygen.R
-#' #' @@include collate.R
+#' #' `example-a.R', `example-b.R' and `example-c.R' reside
+#' #' in the `example' directory, with dependencies
+#' #' a -> {b, c}. This is `example-a.R'.
+#' #' @@include example-b.R
+#' #' @@include example-c.R
#' roxygen()
#'
#' roclet <- make.collate.roclet()
-#' \dontrun{roclet$parse('example.R')}
+#' \dontrun{roclet$parse.dir('example')}
#' @export
make.collate.roclet <- function(merge.file=NULL,
target.file='',
@@ -120,6 +123,9 @@
sprintf("'%s'", vertex$file),
topological.sort(vertices),
' '))
+ if (!is.null(cwd))
+ setwd(cwd)
+ assign.parent('cwd', NULL, environment())
if (!is.null(merge.file))
merge(directive)
else
@@ -132,5 +138,16 @@
roclet$register.default.parser('include')
+ cwd <- NULL
+
+ roclet$parse.dir <- function(dir) {
+ assign.parent('cwd', getwd(), environment())
+ setwd(dir)
+ do.call(roclet$parse,
+ as.list(list.files('.',
+ recursive=TRUE,
+ full.names=FALSE)))
+ }
+
roclet
}
Modified: pkg/R/roxygenize.R
===================================================================
--- pkg/R/roxygenize.R 2008-07-27 04:29:31 UTC (rev 103)
+++ pkg/R/roxygenize.R 2008-07-27 04:44:24 UTC (rev 104)
@@ -61,8 +61,8 @@
roxygen.dir <- sprintf(ROXYGEN.DIR, package.dir)
man.dir <- file.path(roxygen.dir, MAN.DIR)
namespace.file <- file.path(roxygen.dir, NAMESPACE.FILE)
- package.description <- file_path_as_absolute(file.path(package.dir, DESCRIPTION.FILE))
- roxygen.description <- file_path_as_absolute(file.path(roxygen.dir, DESCRIPTION.FILE))
+ package.description <- file.path(package.dir, DESCRIPTION.FILE)
+ roxygen.description <- file.path(roxygen.dir, DESCRIPTION.FILE)
skeleton <- c(roxygen.dir, man.dir)
if (copy.package)
@@ -79,9 +79,7 @@
do.call(Rd$parse, files)
namespace <- make.namespace.roclet(namespace.file)
do.call(namespace$parse, files)
- setwd(r.dir)
- files <- as.list(list.files('.', recursive=TRUE))
collate <- make.collate.roclet(merge.file=package.description,
target.file=roxygen.description)
- do.call(collate$parse, files)
+ collate$parse.dir(r.dir)
}
More information about the Roxygen-commits
mailing list