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 セクションが見つかりません...