I have a number of functions that have related methods with different arguments that I want to document together within the generic. Is there a standard method for documenting arguments passed through an ellipsis to the different methods by an S4 generic? Ideally, I'd like to group together arguments passed to the different methods for maximum readability.
Here is how I'm currently trying to do this based on what I read in Documenting multiple functions in the same file:
#' A class
#' @export
setClass("A", slots = c(a = 'numeric'))
#' B class
#' @export
setClass("B", slots = c(b = 'numeric'))
#' foo generic
#'
#' foo generic description
#'
#' @param object The object
#' @param x shared argument
#' @param ... other arguments passed to methods
#' @export
setGeneric("foo", function(object, x, ...) standardGeneric("foo"))
#' foo method A
#'
#' foo method A description
#'
#' @param y method A argument
#' @rdname foo
#' @export
setMethod("foo", "A", function(object, x, y = 1) {NULL})
#' foo method B
#'
#' foo method B description
#'
#' @param z method B argument
#' @rdname foo
#' @export
setMethod("foo", "B", function(object, x, z = 2) {NULL})
The result is quite close to what I want, but all the extra arguments are simply lumped together after the ellipses.
Usage:
foo(object, x, ...)
## S4 method for signature 'A'
foo(object, x, y = 1)
## S4 method for signature 'B'
foo(object, x, z = 2)
Arguments:
object: The object
x: shared argument
...: other arguments passed to methods
y: method A argument
z: method B argument
Is there a way to explicitly mark parameters as belonging to a specific method/class (without just writing it out in the description) similar to the usage section, or should I be using a completely different structure?