我正在尝试为R6类生成一些合理的文档。这是一个示例:
##' 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()
是我为定义R6方法编写的辅助函数。
有些东西在这里不起作用:
@inheritParams
指令不起作用,name
的{{1}}和deps
和create
自变量没有被继承。这会生成myOtherMethod()
之类的R CMD check
警告Undocumented arguments in documentation object 'myOtherMethod'
‘name’ ‘deps’ ‘create’
指令,因为Roxygen无法(相当合理地)弄清楚如何解析我的方法定义。有更好的方法吗?@usage
中,我收到有关R CMD check
的警告我还有一个更富成果的方向去吗?我应该尝试记录Functions or methods with usage in documentation object 'myMethod' but not in code:
myMethod
对象而不是NULL
调用吗?那会是什么样?