如何在Rd文件中使用roxygen2为S4方法自动填充使用标记

Jor*_*eys 5 r help-files s4 roxygen2

我有一个包含S3和S4方法组合的包(是的,我知道,但尝试为sort()编写一个S4,as.matrix()等等...).所以我坚持使用CRAN的经典roxygen2(版本2.2.2)

我注意到无论我尝试什么,我都无法在Rd文件中获得自动填充的用法标记.我知道我可以使用@usage手工完成,但我想保持自动化,因为我有一个相当广泛的代码库,我不想错过任何地方的标签.

一个例子:

#' 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})
Run Code Online (Sandbox Code Playgroud)

如果我将它包装在一个包中,使用roxygen2(和RStudio,如果这很重要)进行roxygenize,并检查帮助文件,它看起来像这样:

\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
}
Run Code Online (Sandbox Code Playgroud)

找不到\用法部分......