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 %||% dirname(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),
  error = function(e) {
    cat(e$stderr)
    stop("Failed to build manual", call. = FALSE)
  })

  cat(msg$stdout)
  invisible(msg)
}
thierrymoudiki/devtools documentation built on July 28, 2020, 12:58 a.m.