Documenting S3 Methods with Roxygen2

This post is primarily intended for personal documentation. I have been incredibly confused by how to go about documenting S3 Methods in R, and things have gotten worse with the transition to Roxygen2 4.0 (or perhaps 3.0, whenever @export gained auto-S3 detection). This is what I’ve figured out so far:

@export will write export namespace directives for normal functions and S3method namespace directives for functions it detects as S3 methods. Not entirely sure if the S3 detection is just looking for a period, or something else. Corollary: @export will NOT write an export directive for S3methods!

@S3method will write the S3method namespace directive, but is deprecated as of Roxygen2 4.0.

@method produces the documentation entry corresponding to a method, e.g.:

but this will only happen if there is text in addition to @method in the roxygen block, or if you assign the @method block to a different Rd file with @rdname.

Leave a Reply

Your email address will not be published. Required fields are marked *