Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
35 lines (32 sloc) 1014 Bytes
#' Use roxygen to document a package.
#'
#' This function is a wrapper for the [roxygen2::roxygenize()]
#' function from the roxygen2 package. See the documentation and vignettes of
#' that package to learn how to use roxygen.
#'
#' @template devtools
#' @inheritParams roxygen2::roxygenise
#' @param quiet if `TRUE` suppresses output from this function.
#' @seealso [roxygen2::roxygenize()],
#' `browseVignettes("roxygen2")`
#' @export
document <- function(pkg = ".", roclets = NULL, quiet = FALSE) {
pkg <- as.package(pkg)
if (!isTRUE(quiet)) {
cli::cli_alert_info("Updating {.pkg {pkg$package}} documentation")
}
save_all()
if (pkg$package == "roxygen2") {
# roxygen2 crashes if it reloads itself
load_all(pkg$path, quiet = quiet)
}
if (quiet) {
output <- tempfile()
on.exit(unlink(output))
withr::local_output_sink(output)
}
withr::local_envvar(r_env_vars())
roxygen2::roxygenise(pkg$path, roclets)
pkgload::dev_topic_index_reset(pkg$package)
invisible()
}