How to get usage tag automatically filled in with roxygen2 in Rd files for S4 methods

216 views Asked by At

I have a package with a combination of S3 and S4 methods (yeah, I know, but try to write an S4 for sort(), as.matrix() and the likes...). So I stick with the classic roxygen2 from CRAN (version 2.2.2)

I've noticed that whatever I try, I can't get the usage tag in the Rd files get filled in automatically. I know I can do that by hand using @usage, but I want to keep it automated, as I have a rather extensive code base and I don't want to miss a tag somewhere by accident.

An example:

#' A small test function
#' 
#' This function tests roxygen2
#' @param x that's right, it's called x
#' @param ... some more stuff
#' 
#' @rdname testfun-methods
#' @aliases testfun
#' @docType methods
#' @export
setGeneric("testfun",function(x,...) standardGeneric("testfun"))

#' @rdname testfun-methods
#' @aliases testfun,matrix-method
#' @return the matrix minus 1
setMethod("testfun","matrix",function(x,...){x - 1})

#' @rdname testfun-methods
#' @aliases testfun,numeric-method
#' @return a vector plus 1
setMethod("testfun","matrix",function(x,...){x + 1})

If I wrap this in a package, roxygenize using roxygen2 (and RStudio, if that matters), and check the help file, it looks like this:

\docType{methods}
\name{testfun}
\alias{testfun}
\alias{testfun,matrix-method}
\alias{testfun,numeric-method}
\title{A small test function}
\arguments{
  \item{x}{that's right, it's called x}

  \item{...}{some more stuff}
}
\value{
  the matrix minus 1

  a vector plus 1
}
\description{
  This function tests roxygen2
}

No \usage section to be found...

0

There are 0 answers