klutometis/roxygen — Issue #79: Can't document new S4 generics if defined inside setGeneric()
Author: garrettgman
Created: 2012-02-07 16:44:30+00:00
State: open

I find the following behavior when I use the document() wrapper of roxygenise from Hadley's devtools package. If I create a new generic like so

#' My foo function
#'
#' foo will have S4 methods
#' export
setGeneric("foo", function(object){
standardGeneric("foo")
})

document() produces the error message

Error in function (classes, fdef, mtable) :
unable to find an inherited method for function "topic_name", for signature "nonstandardGenericFunction"

(note: topic_name comes from the error. It is not the real name of foo.)
If I instead define a function foo and then make it generic, things work. i.e,

#' My foo function
#'
#' foo will have S4 methods
#' @export
foo <- function(object) standardGeneric("foo")

#' @export
setGeneric("foo")

Garrett