当多个参数匹配时,如何在单个参数上使用@inheritParams?
我想记录一个R函数,并在多个参数名称匹配时从其他函数继承单个参数文档。例如,假设我有以下两个函数当多个参数匹配时,如何在单个参数上使用@inheritParams?,r,devtools,roxygen2,R,Devtools,Roxygen2,我想记录一个R函数,并在多个参数名称匹配时从其他函数继承单个参数文档。例如,假设我有以下两个函数 #' Function 1. #' #' Description of function 1. #' #' @param x XYZ #' @param y ZYX #' @return Numeric fun1 <- function(x, y) {value <- 1} #' Function 2. #' #' Description of function 2. #' #
#' Function 1.
#'
#' Description of function 1.
#'
#' @param x XYZ
#' @param y ZYX
#' @return Numeric
fun1 <- function(x, y) {value <- 1}
#' Function 2.
#'
#' Description of function 2.
#'
#' @param x ABC
#' @param y CBA
#' @return Numeric
fun2 <- function(x, y) {value <- 2}
函数1。
#'
#'功能1的说明。
#'
#“@param x XYZ
#“@param y ZYX
#“@返回数字
fun1您也可以使用
roxygen2
模板作为参数:
- 创建一个名为
的文件夹manroxygen
- 在
中添加一行.Rbuildignore
^man roxygen
- 在该文件夹中,您可以创建包含文档片段的R文件。
例如,假设您有一个文件
,其中包含:x-arg.R
- @param x My x参数。
- 在要使用相同文档片段的所有函数中,
编写
而不是@template x-arg
@param bla bla
- 利润
@param
条目
我相信这适用于任何你想重复的文档,
虽然有些情况需要特殊处理。
例如,如果您希望有一个模板,其中包含一些应该放在特定部分下的文本(例如“详细信息”),
R模板文件中的代码段还必须具有相应的指令,
如果有其他特定文本,则可能需要重复该指令才能使用:
在详细信息模板中.R
#' @details
#'
#' Text that should appear everywhere
使用它
#' @details
#'
#' Some specific text.
#'
#' @template details-template
#' @details
#'
#' Text that should appear everywhere
#' @details
#'
#' Some specific text.
#'
#' @template details-template