I've seen some discussions in SO and other places regarding how this should be or will be done in future versions of Roxygen2. However, I am stuck. How should I go about documenting a S4 generic, as well as its methods, using Roxygen2? A working example for a brand new generic/methods, as well as an example for extending base S4 generic would be incredibly useful. I do not want to have to make separate (mostly) redundant documentation for each S4 method of the same generic.
Due dilligence: I have tracked down a useful example for the "extract" method. However, it appears to be outdated and incomplete for my question. It uses @slot tag in the class documentation, which is not (no longer?) supported. It only shows an extension of a core S4 method "[", rather than a complete Roxygen example including the documentation of the S4 generic.
How to properly document S4 "[" and “[<-“ methods using roxygen?
If I fully document a new S4 generic with title, description @param @return @name @aliases
@docType @rdname
, and then document the S4 method with just the corresponding @name @aliases
@docType @rdname
, I get the following R CMD check
warning:
* checking for missing documentation entries ... WARNING
Undocumented S4 methods:
<< long list of apparently undocumented methods. E.g. generic 'plot' and siglist 'myClass1,ANY' >>
All user-level objects in a package (including S4 classes and methods)
should have documentation entries.
It looked at first as though none of my S4 methods documented in this fashion with roxygen2 had actually worked. However, so far, I've noticed that my extensions of the core method "show" do not have an associated error, even though they were documented in exactly the same way as the rest. Here is an example of the complete roxygen documentation I included above one of the show methods, that did NOT generate the missing-documentation error:
#' @name show
#' @aliases show,myClass2-method
#' @docType methods
#' @rdname show-methods
Thus, I'm at a loss. As you can see, I've included the convention for aliases for S4 methods described in the S4 documentation section of the R package manual, namely that methods should have an alias with the following name (without space):
generic,signature_list-method.
Somehow, this is not completely being understood by R CMD check
.
Finally, after building the documentation using:
library("devtools")
library("roxygen2")
document("mypkgname")
check_doc("mypkgname")
and building the package, I get functioning documentation. Any titles from a specific method's documentation winds up in the 'Description' field, rather awkwardly. So roxygen2 obviously did something with each method's documentation and is on the right track. However, it is not enough to avoid a large and troubling warning from
> R CMD check mypkgname
I've looked at the Rd files, but I know even less about them to quickly see what's the problem is, and I anyway want to know the roxygen2 solution so that I will not have to manipulate the Rd files directly after each documentation revision.
So this is a multipart question:
What is the current recommended approach for both S4 generic and S4 method documentation with roxygen2?
Is there a good example available somewhere that shows the complete details?
What might be the cause, and solution, to the warning that documentation for most S4 methods is missing (even though the methods with "missing" documentation actually have had their doc parsed by roxygen2 and the resulting Rd files are at least good enough to work in the package after
R CMD build mypkgname
) ?