do not show function help document in building R package by roxygen2

泄露秘密 提交于 2019-12-03 11:24:23
alittleboy

According to Hadley's comments, use @keywords internal will make the function invisible to end-users. Details can be found here in the wiki pages of devtools.

The wiki linked in the accepted answer no longer discusses @keywords internal (as of April 2016). In case it's helpful for someone to see an example:

# 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)
}

Key bits: do not include @export and do include @keywords internal

For me, @keywords internal did not work (roxygen2 6.1.1). I was able to achieve the desired result using the following in my roxygen comments:

@noRd
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!