[Roxygen-commits] r41 - in pkg: R sandbox

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 19 03:18:19 CEST 2008


Author: pcd
Date: 2008-06-19 03:18:19 +0200 (Thu, 19 Jun 2008)
New Revision: 41

Modified:
   pkg/R/parse.R
   pkg/sandbox/example-S3-mcpi.R
   pkg/sandbox/main.R
Log:
possible S3 solution


Modified: pkg/R/parse.R
===================================================================
--- pkg/R/parse.R	2008-06-18 23:23:11 UTC (rev 40)
+++ pkg/R/parse.R	2008-06-19 01:18:19 UTC (rev 41)
@@ -40,10 +40,6 @@
 parse.warning <- function(key, message)
   warning(parse.message(key, message))
 
-parse.preref <- function(...) {
-  list(unknown=paste(...))
-}
-
 parse.element <- function(element) {
   tokens <- car(strsplit(element, ' ', fixed=T))
   parser <- parser.preref(car(tokens))
@@ -61,6 +57,8 @@
 parse.default <- function(key, ...)
   as.list(structure(args.to.string(...), names=key))
 
+parse.preref <- Curry(parse.default, key='unknown')
+
 ## Possibly NA; in which case, the Roclets can do something more
 ## sophisticated with the srcref.
 parse.export <- Curry(parse.default, key='export')
@@ -90,6 +88,8 @@
 
 parse.importMethodsFrom <- Curry(parse.value, key='importMethodsFrom')
 
+parse.return <- Curry(parse.value, key='importMethodsFrom')
+
 parse.name.description <- function(key, name, ...) {
   if (any(is.na(name),
           is.empty(...)))
@@ -114,6 +114,8 @@
 
 parse.S3class <- Curry(parse.name, key='S3class')
 
+parse.returnType <- Curry(parse.name, key='returnType')
+
 parse.toggle <- function(key, ...)
   as.list(structure(T, names=key))
 

Modified: pkg/sandbox/example-S3-mcpi.R
===================================================================
--- pkg/sandbox/example-S3-mcpi.R	2008-06-18 23:23:11 UTC (rev 40)
+++ pkg/sandbox/example-S3-mcpi.R	2008-06-19 01:18:19 UTC (rev 41)
@@ -1,14 +1,21 @@
 # S3 documentation using Roxygen.
 
+#' Container for the number of throws and pi estimation.
+#'
+#' @S3class mcpi
+#' @slot pi Estimation of pi
+#' @slot throws Number of throws
+#' @listObject
+NA
 
-
 #' A monte carlo algorithm to calculate PI. Extended
 #' version which returns the throws.
 #'
 #' @param trials The number of trials to throw
-#'
-#' @return mcpi a list containing the approximated
-#'              PI value and the throws
+#' @returnType mcpi
+#' @return a list containing the approximated
+#'         PI value and the throws
+#' @export mcpiX
 mcpiX <- function(trials) {
 
   throws <- matrix(NA, nrow=trials,
@@ -34,18 +41,21 @@
 }
 
 #' Print function for 'mcpi' objects.
+#'
 #' @param x The 'mcpi' object
 #' @param ... Ignored
 #' @return NULL
+#' @S3method print mcpi
 print.mcpi <- function(x, ...) {
   cat('Approximated PI value (using', nrow(x$throws), 'throws) =', x$pi, '\n')
 }
 
 #' Plot function for 'mcpi' objects.
+#'
 #' @param x The 'mcpi' object
 #' @return NULL
-#'
-#' @import pgirmess polycircle 
+#' @importFrom pgirmess polycircle
+#' @S3method plot mcpi
 plot.mcpi <- function(x, ...) {
   plot(x$throws[,1:2], col=x$throws[,3]+1,
        xlim=c(0,1), ylim=c(0,1), pch=19,
@@ -56,14 +66,17 @@
 }
 
 #' Return base data of a monte carlo algorithm.
+#'
 #' @param x A object created with a monte carlo algorithm
 mcbase <- function(x, ...) {
   UseMethod('mcbase')
 }
 
 #' Base of PI approximation with motne carlo algorithm.
+#'
 #' @param x The 'mcpi' object
 #' @return The throws
+#' @S3method mcbase mcpi
 mcbase.mcpi <- function(x, ...) {
   return(x$throws)
 }

Modified: pkg/sandbox/main.R
===================================================================
--- pkg/sandbox/main.R	2008-06-18 23:23:11 UTC (rev 40)
+++ pkg/sandbox/main.R	2008-06-19 01:18:19 UTC (rev 41)
@@ -2,7 +2,7 @@
 source('../R/list.R')
 source('../R/parse.R')
 
-FILE <- 'example.R'
+FILE <- 'example-S3-mcpi.R'
 
 argv <- commandArgs(trailingOnly=T)
 argc <- length(argv)



More information about the Roxygen-commits mailing list