I'm trying to generate some reasonable documentation for R6 classes. Here's an example:
##' GroveR class object
##' @importFrom R6 R6Class
##' @export
GroveR <- R6Class(
portable = FALSE,
private = list(
fileRoot = ".",
artDefs = list(),
memCache = list()
)
)
.public <- function(...) GroveR$set("public", ...)
#' Do a thing
#'
#' @name myMethod
#' @usage
#' myMethod(name, deps, create, retrieve, checkTime,
#' store, clobber=FALSE)
#'
#' @param name name of the artifact
#' @param deps names of other artifacts this artifact depends on
#' @param create function to create this artifact object from its dependency objects
#' @param retrieve function to retrieve this artifact from cache
#' @param checkTime function to fetch the time of last update for this artifact
#' @param store function to store this artifact to cache
#' @param clobber whether to allow redefinition of this artifact if it is already defined
.public("myMethod", function(name, deps, create, retrieve, checkTime, store, clobber=FALSE) {
# ...body...
}
#' Do a similar thing
#'
#' @name myOtherMethod
#' myOtherMethod(name, deps, create, path, readFun=readRDS,
#' writeFun=saveRDS, ...)
#'
#' @inheritParams myMethod // TODO Doesn't work yet
#' @param path path to cached file
#' @param readFun function to read file from disk
#' @param writeFun function to write file to disk
#' @param ... further arguments passed to \link{myMethod}
.public("myOtherMethod", function(name, deps, create, path, readFun=readRDS, writeFun=saveRDS, ...) {
# ...body...
}
.public()
is a helper function I've written for defining R6 methods.
There are several things not working here:
- The
@inheritParams
directive is not working, thename
anddeps
andcreate
argument formyOtherMethod()
are not being inherited. This generatesR CMD check
warnings likeUndocumented arguments in documentation object 'myOtherMethod' ‘name’ ‘deps’ ‘create’
- I'm adding the
@usage
directive manually, because Roxygen can't figure out (quite reasonably) how to parse my method definitions. Is there a better way to do this? - In
R CMD check
, I get warnings aboutFunctions or methods with usage in documentation object 'myMethod' but not in code: myMethod
Is there a more fruitful direction for me to go? Should I try documenting a NULL
object instead of my .public
calls? What would that look like?