File: build-site.R

package info (click to toggle)
r-cran-devtools 2.4.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,328 kB
  • sloc: sh: 15; makefile: 5
file content (32 lines) | stat: -rw-r--r-- 907 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#' Execute \pkg{pkgdown} build_site in a package
#'
#' `build_site()` is a shortcut for [pkgdown::build_site()], it generates the
#'   static HTML documentation.
#'
#' @param path path to the package to build the static HTML.
#' @param ...  additional arguments passed to [pkgdown::build_site()]
#' @inheritParams install
#'
#' @return NULL
#' @export
build_site <- function(path = ".", quiet = TRUE, ...) {
  rlang::check_installed("pkgdown")

  save_all()

  pkg <- as.package(path)

  check_dots_used(action = getOption("devtools.ellipsis_action", rlang::warn))

  withr::with_temp_libpaths(action = "prefix", code = {
    install(pkg = pkg$path, upgrade = "never", reload = FALSE, quiet = quiet)
    if (isTRUE(quiet)) {
      withr::with_output_sink(
        file_temp(),
        pkgdown::build_site(pkg = pkg$path, ...)
      )
    } else {
      pkgdown::build_site(pkg = pkg$path, ...)
    }
  })
}