5

我有一个包含 S3 和 S4 方法组合的包(是的,我知道,但尝试为 sort()、as.matrix() 等编写一个 S4 ......)。所以我坚持使用 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})

如果我将它包装在一个包中,使用 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
}

找不到 \usage 部分...

4

0 回答 0