R/build-manual.R

Defines functions build_manual

Documented in build_manual

#' Create package pdf manual
#'
#' @template devtools
#' @param path path in which to produce package manual.
#'   If `NULL`, defaults to the parent directory of the package.
#'
#' @seealso [Rd2pdf()]
#' @export
build_manual <- function(pkg = ".", path = NULL) {
  pkg <- as.package(pkg)
  path <- path %||% path_dir(pkg$path)
  name <- paste0(pkg$package, "_", pkg$version, ".pdf", collapse = " ")
  tryCatch(msg <- callr::rcmd("Rd2pdf", cmdargs = c(
    "--force",
    paste0("--output=", path, "/", name),
    pkg$path
  ), fail_on_status = TRUE, stderr = "2>&1", spinner = FALSE),
  error = function(e) {
    cat(e$stdout)
    cli::cli_abort("Failed to build manual")
  })

  cat(msg$stdout)
  invisible(msg)
}
r-lib/devtools documentation built on Feb. 17, 2024, 5:32 p.m.