Documenting R.oo classes / methods with Roxygen

Can someone point me to a good example of documenting R.oo classes / methods with Roxygen? In R.oo, classes / methods are created by calling setConstructorS3 () and setMethodS3 (), so there is no function to document per se. You just create standard Roxygen function documentation, but put it on top of the NULL statement?

+5
source share
2 answers

After some trial and error, this is what I came up with. This solution ensures that all objects are exported properly, that the R CMD build / check does not shine, that there is no redundant documentation and that the examples will be executed. Note that the solution will not work if @export is replaced with @ method / @ S3method. Theoretically, this should work, but it is not for me. Does anyone 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 ) { ... } )
+2
source

I think,

  • @usage.
  • The dot-dot-dot argument is required in the function MyMethod.ClassNamefor S3 generic / method consistency.
  • Not #' @export MyMethod.ClassName, but rather #' @S3method MyMethod ClassName?

Code example:

#' 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
})
+3
source

All Articles