使用 roxygen 固定参数描述的顺序

问题描述 投票:0回答:1

我正在尝试整合一组函数的文档。然而,这些函数并不具有完全相似的参数集。相反,它们是相关的,因为它们作用于 REDCap 项目中的同一表系统。

我已经能够将所有函数放入同一个 .Rd 文件中,但我对

roxygen2
如何对文档中的参数进行排序(即按照它发现不同的顺序)感到不兴奋使用部分中的参数(参见图片)。

我是否正确地认为没有办法强制固定的参数顺序?我还没有找到任何可以让我控制顺序的东西。

我希望参数按顺序出现

#' @param rcon A \code{redcapConnection} object.
#' @param arms \code{character} or \code{integerish} identifying the arm 
#'   numbers to export or delete.
#' @param data A \code{data.frame} with two columns.  The first column 
#'   (\code{arm_num}) is an integerish value . The second (\code{name}) is
#'   a character value. For backward compatibility, 
#'   this may also be passed as \code{arms_data}.
#' @param override \code{logical(1)}. By default, data will add to or modify 
#'   existing arms data. When \code{TRUE}, all the existing arms data is 
#'   deleted and replaced with the contents of \code{data}.
#' @param refresh \code{logical(1)} If \code{TRUE}, the cached arms data will
#'   be refreshed after the API action is complete.
#' @param ... Arguments to pass to other methods
#' @param error_handling \code{character(1)}. One of \code{c("error", "null")}.
#'   An option for how to handle errors returned by the API.
#'   see \code{\link{redcapError}}.
#' @param config A named \code{list}. Additional configuration parameters to pass to
#'   \code{\link[httr]{POST}}. These are appended to any parameters in
#'   \code{rcon$config}.
#' @param api_param A named \code{list}. Additional API parameters to pass into the
#'   body of the API call. This provides users to execute calls with options
#'   that may not otherwise be supported by \code{redcapAPI}.

r roxygen2
1个回答
0
投票

@r2evans 提供了 roxygen 存储库中问题的链接以及解决方法。 (github.com/r-lib/roxygen2/issues/1475)

我现在的解决方案是:

#' @param rcon A \code{redcapConnection} object.
#' @param arms \code{character} or \code{integerish} identifying the arm 
#'   numbers to export or delete.
#' @param data A \code{data.frame} with two columns.  The first column 
#'   (\code{arm_num}) is an integerish value . The second (\code{name}) is
#'   a character value. For backward compatibility, 
#'   this may also be passed as \code{arms_data}.
#' @param override \code{logical(1)}. By default, data will add to or modify 
#'   existing arms data. When \code{TRUE}, all the existing arms data is 
#'   deleted and replaced with the contents of \code{data}.
#' @param refresh \code{logical(1)} If \code{TRUE}, the cached arms data will
#'   be refreshed after the API action is complete.
#' @param ... Arguments to pass to other methods
#' @param error_handling \code{character(1)}. One of \code{c("error", "null")}.
#'   An option for how to handle errors returned by the API.
#'   see \code{\link{redcapError}}.
#' @param config A named \code{list}. Additional configuration parameters to pass to
#'   \code{\link[httr]{POST}}. These are appended to any parameters in
#'   \code{rcon$config}.
#' @param api_param A named \code{list}. Additional API parameters to pass into the
#'   body of the API call. This provides users to execute calls with options
#'   that may not otherwise be supported by \code{redcapAPI}.
#' @usage NULL
#' @order 0

dummyFunctionName <- function(rcon, arms, data, override, refresh, ..., 
                              error_handling, config, api_param){ NULL }

@usage NULL
会阻止
dummyFunctionName
的使用包含在文档中。

@order 0
dummyFunctionName
中的参数置于查找新参数名称时首先搜索的参数。

缺少

@export
标签会导致
dummyFunctionName
无法导出。

© www.soinside.com 2019 - 2024. All rights reserved.