Could someone point me to a good example of documenting R.oo classes/methods with Roxygen? In R.oo, classes/methods are created by calls to setConstructorS3() and setMethodS3(), so there is no function to document per-se. Do you simply create standard Roxygen function documentation, but place it on top of a NULL statement?
The goal of roxygen2 is to make documenting your code as easy as possible. R provides a standard way of documenting packages: you write . Rd files in the man/ directory. These files use a custom syntax, loosely based on LaTeX. roxygen2 provides a number of advantages over writing .
Inserting a skeleton - Do this by placing your cursor anywhere in the function you want to document and click Code Tools -> Insert Roxygen Skeleton (default keyboard shortcut Ctrl+Shift+Alt+R ).
One of the core requirements for R packages is that all exported functions, objects, and datasets have complete documentation.
I think,
@usage
are needed.MyMethod.ClassName
function for S3 generic/method consistency.#' @export MyMethod.ClassName
but rather #' @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
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With