我正在使用devtools
来构建R包,并且有些功能并非设计为最终用户可见。但是,由于这些函数涉及通过.Call
调用C代码,因此我必须在函数上方编写@useDynLib
以自动生成.Rd文件。这样,当我构建软件包时,即使我没有为这些函数包含@export
,它们仍会出现在帮助文档中......有没有办法抑制这些函数,即使它们已被记录?谢谢!
根据Hadley的评论,使用@keywords internal
将使该功能对最终用户不可见。详细信息可以在here的wiki页面找到devtools
。
在接受的答案中链接的维基不再讨论@keywords internal
(截至2016年4月)。如果有人看到一个例子是有帮助的:
# multiplyBy3
#' This is an example of an internal function called \code{multiplyBy3()}
#'
#' Sometimes you want internal functions as part of an R Package built with
#' RStudio and roxygen2, but you don't want .Rd files created for them
#' or to have them be visible in the help document following the build process
#'
#' @keywords internal
#'
#' @param base_num The number to multiply by three
#'
#' @import jsonlite
#'
#' @return Returns a numeric vector
#'
multiplyBy3 <- function(base_number) {
stopifnot(is.numeric(base_number))
return(base_number * 3)
}
关键位:不包括@export
并且包括@keywords internal
对我来说,@keywords internal
不起作用(roxygen2 6.1.1)。在我的roxygen评论中,我能够使用以下内容实现所需的结果:
@noRd