Skip to contents

Validates your package sources and builds the pkgdown site in a temporary copy, leaving your man/ files, NAMESPACE, README.md, and docs/ folder untouched. Handy in CI, scripts, and AI agent edit-verify loops.

Usage

check(
  pkg = ".",
  document = TRUE,
  quiet = FALSE,
  format = c("text", "json"),
  error = TRUE,
  pandoc = getOption("updoc.pandoc", NULL)
)

Arguments

pkg

Path to an R package (or any file or folder inside it). Defaults to the current directory (".").

document

Whether to run roxygen2 in the temporary copy before building. Set to FALSE if you manage man/ files yourself. R syntax is still checked, and README.Rmd is still rendered if present.

quiet

Whether to hide detailed pkgdown output. Always treated as TRUE when format = "json" so standard output stays valid JSON.

format

Output format:

  • "text" (default): print a readable summary and structured diagnostics.

  • "json": print one JSON object (ok, package_root, duration, warnings, error, and build_log) to standard output.

error

Whether to signal an error if the build fails. Defaults to TRUE so Rscript -e "updoc::check()" exits with a non-zero status on failure. Set to FALSE to inspect the returned updoc_check object without throwing.

pandoc

Path to the directory containing the pandoc binary (version 2.10.1 or newer). When NULL (the default), updoc uses the Pandoc found by rmarkdown. Set options(updoc.pandoc = "/path/to/bin") to reuse a specific directory across builds. updoc never downloads Pandoc or changes your system installation.

Value

Invisibly, an updoc_check object with ok, package_root, duration, warnings, error, and build_log. When error = TRUE and the check fails, the thrown error message includes the log path and the condition carries $build_log and $check.

Details

Like serve() and preview(), check() checks R syntax and article YAML front matter, runs roxygen2 (unless document = FALSE), renders README.Rmd if present, and builds the site in isolation. Temporary site files are deleted before returning, while the full build log stays in the current R session's temporary directory.

Examples

if (interactive()) {
  # Verify the site without touching generated files in your package.
  check()

  # Emit machine-readable JSON for scripts or AI agents.
  check(format = "json", error = FALSE)
}