[英]Documenting R.oo classes/methods with Roxygen
Could someone point me to a good example of documenting R.oo classes/methods with Roxygen? 有人可以指出我一个用Roxygen记录R.oo类/方法的好例子吗? In R.oo, classes/methods are created by calls to setConstructorS3() and setMethodS3(), so there is no function to document per-se. 在R.oo中,类/方法是通过对setConstructorS3()和setMethodS3()的调用来创建的,因此本身没有文档功能。 Do you simply create standard Roxygen function documentation, but place it on top of a NULL statement? 您是否只是创建标准的Roxygen函数文档,但将其放在NULL语句之上?
I think, 我认为,
@usage
are needed. @usage
是必需的。 MyMethod.ClassName
function for S3 generic/method consistency. 为了实现S3通用/方法的一致性, MyMethod.ClassName
函数中需要一个点-点-点参数。 #' @export MyMethod.ClassName
but rather #' @S3method MyMethod ClassName
? 不是#' @export MyMethod.ClassName
#' @S3method MyMethod ClassName
而是#' @S3method MyMethod ClassName
吗? An example code: 示例代码:
#' Title. More Info.
#'
#' @usage MyMethod(...)
#' @param this this.
#' @param someParam Param info.
#' @param ... other arguments.
#'
#' @rdname MyMethod
#' @export MyMethod
#' @name MyMethod
NULL
#' @usage \method{MyMethod}{ClassName}(this, someParam, ...)
#' @return MyMethod.ClassName:
#' \code{NULL}
#'
#' @rdname MyMethod
#' @S3method MyMethod ClassName
#' @name MyMethod.ClassName
setMethodS3("MyMethod", "ClassName", appendVarArgs = FALSE,
function(this, someParam, ...) {
NULL
})
After some trial & error, here's what I came up with. 经过一番尝试和错误后,这就是我的想法。 This solution ensures that all objects are exported properly, that R CMD build/check does not puke, that there is no redundant documentation, and that examples will execute. 此解决方案可确保正确导出所有对象,不会吐出R CMD构建/检查,没有多余的文档,并且可以执行示例。 Note that the solution won't work if @export is replaced with @method/@S3method. 请注意,如果将@export替换为@ method / @ S3method,则该解决方案将不起作用。 Theoretically that should work, but it didn't for me. 从理论上讲应该可以,但是对我来说不是。 Someone have a better solution? 有人有更好的解决方案吗?
#' Title. More Info.
#'
#' @param someParam Param info.
#'
#' @name MyMethod
#' @export MyMethod
NULL
#' @rdname MyMethod
#' @name MyMethod.ClassName
#' @export MyMethod.ClassName
setMethodS3( "MyMethod" , "ClassName" , appendVarArgs = FALSE ,
function( this , someParam ) { ... } )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.