[Roxygen-devel] Roxygen2 3.0.0

Hadley Wickham h.wickham at gmail.com
Tue Jan 21 21:33:24 CET 2014


> If I just do:
>
>     #' @rdname c-codeDefinition
>     setMethod("c", signature("codeDefinition"), function(x, ...)
> new("ListOfcodeDefinition", list(x, ...)))
>
> Then check complains about missing \name and \title for the method.

I meant @rdname class-codeDefinition - but you'll need to check that's
the name of the generated class file in man/

> If I add a name and title:
>
> #' concatenate
> #'
> #' concatenate
> #' @rdname c-codeDefinition
> setMethod("c", signature("codeDefinition"), function(x, ...)
> new("ListOfcodeDefinition", list(x, ...)))
>
>
> Check complains
>
> * checking for code/documentation mismatches ... WARNING
> Codoc mismatches from documentation object 'c,codeDefinition-method':
> \S4method{c}{codeDefinition}
>   Code: function(x, ..., recursive = FALSE)
>   Docs: function(x, ...)
>   Argument names in code not in docs:
>     recursive

If you do getGeneric("c") you see

function (x, ..., recursive = FALSE)
standardGeneric("c", .Primitive("c"))

so your method needs to be

setMethod("c", signature("codeDefinition"), function(x, ..., recursive
= FALSE) {
   new("ListOfcodeDefinition", list(x, ...))
})

Though that's a bit suboptimal because it allows you to concatenate
together any objects with codeDefinitions, which is probably not what
you want. In particular you should probably handle
ListOfcodeDefinitions specially so that c() maintains its usual
flattening behaviour.

Next you need to provide enough documentation that check passes - if
you're documenting in a file with other components it's usually enough
to document all the params. Maybe:

#' @param x,... codeDefinitions to concatenate
#' @param recursive Needed for compatibility with generic, otherwise ignored

But it will depend on what else you're documenting in that file. I'm
not sure what's best practice here - a lot of S4 documentation is not
very easy to use.

Hadley


-- 
http://had.co.nz/


More information about the Roxygen-devel mailing list