Search code examples
rroxygenroxygen2

Documenting R.oo classes/methods with Roxygen


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?


Solution

  • 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. Note that the solution won't work if @export is replaced with @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 ) { ... } )