[Roxygen-commits] r143 - in pkg: R sandbox
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Aug 1 12:44:54 CEST 2008
Author: manuel
Date: 2008-08-01 12:44:53 +0200 (Fri, 01 Aug 2008)
New Revision: 143
Added:
pkg/sandbox/classGraph.R
Modified:
pkg/R/parse.R
Log:
Modified: pkg/R/parse.R
===================================================================
--- pkg/R/parse.R 2008-07-30 15:29:26 UTC (rev 142)
+++ pkg/R/parse.R 2008-08-01 10:44:53 UTC (rev 143)
@@ -56,6 +56,7 @@
#' a function taking \code{key} and \code{expression}
#' @return \code{NULL}
#' @seealso \code{\link{register.parser}}
+#' @export
register.preref.parser <- Curry(register.parser,
table=preref.parsers)
@@ -250,6 +251,7 @@
#' @param key parsing key
#' @param rest the expression to be parsed
#' @return A list with the key and \code{TRUE}
+#' @export
parse.toggle <- function(key, rest)
as.list(structure(TRUE, names=key))
Added: pkg/sandbox/classGraph.R
===================================================================
--- pkg/sandbox/classGraph.R (rev 0)
+++ pkg/sandbox/classGraph.R 2008-08-01 10:44:53 UTC (rev 143)
@@ -0,0 +1,76 @@
+### How to create a external roclet.
+
+require(roxygen)
+
+
+
+#' Exemplar class: the JAVA bicycle class.
+#' @classGraph
+setClass('Bicycle',
+ representation=representation(
+ cadence='numeric',
+ speed='numeric',
+ gear='numeric'))
+
+
+
+#source('../R/parse.R')
+### Roclet:
+register.preref.parser('classGraph', parse.toggle)
+
+make.classGraph.roclet <- function(package, dir='.') {
+
+ ### Prerequirements:
+
+ if ( !require(classGraph) )
+ stop('This roclet needs the ', sQuote('classGraph'), 'package!')
+
+
+ ### Roclet parser:
+
+ class <- NULL
+ file <- NULL
+
+ pre.parse <- function(partitum) {
+ if ( partitum$S4class != '' ) {
+ class <<- partitum$S4class
+ file <<- partitum$srcref$filename
+ }
+ }
+
+ parse.classGraph <- function(key, value) {
+ if ( key == 'classGraph' )
+ if ( !is.null(class) )
+ create.callGraph()
+ else
+ warning('@classGraph set but no S4 class far and wide.')
+ }
+
+ post.parse <- function(partitum) {
+ class <<- NULL
+ file <<- NULL
+ }
+
+ roclet <- roxygen:::make.roclet(parse.classGraph,
+ pre.parse,
+ post.parse)
+
+ roclet$register.default.parsers('classGraph')
+
+
+ ### Action:
+
+ create.callGraph <- function() {
+ print("Hello")
+ }
+
+
+ return(roclet)
+}
+
+
+### Usage:
+
+r <- make.classGraph.roclet()
+r$parse('classGraph.R')
+r$parse('Bicycle.R')
Property changes on: pkg/sandbox/classGraph.R
___________________________________________________________________
Name: svn:keywords
+ Date Revision Author URL Id
Name: svn:eol-style
+ native
More information about the Roxygen-commits
mailing list