| Title: | Live Preview Server for 'pkgdown' Sites |
|---|---|
| Description: | Serves live previews of 'pkgdown' sites while you edit your package. Watches for saved changes, rebuilds affected pages, refreshes the browser, and displays build progress, warnings, and errors. Keeps the last working preview available if a build fails, and leaves generated files in your source package untouched while previewing. |
| Authors: | Leighton Payne [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-2305-6827>), shadcn [cph] (Adapted preview interface patterns and design tokens), Lucide Icons and Contributors [cph] (Preview icons), Cole Bemis [cph] (Feather-derived preview icon) |
| Maintainer: | Leighton Payne <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-11-25 18:23:14 UTC |
| Source: | https://github.com/leightonpayne/updoc |
Builds a complete pkgdown site ready to deploy. Use serve() or preview()
for a live preview while you edit, or check() to verify the site in a
temporary copy without modifying files in your package.
build( pkg = ".", destination = NULL, document = TRUE, lazy = FALSE, quiet = FALSE, pandoc = getOption("updoc.pandoc", NULL) )build( pkg = ".", destination = NULL, document = TRUE, lazy = FALSE, quiet = FALSE, pandoc = getOption("updoc.pandoc", NULL) )
pkg |
Path to an R package (or any file or folder inside it). Defaults
to the current directory ( |
destination |
Optional output folder to write the site into instead of pkgdown's default. Relative paths are resolved from the package root. |
document |
Whether to run roxygen2 before building. Set to |
lazy |
Whether to skip rebuilding reference pages and articles whose output is already newer than their source files. |
quiet |
Whether to hide detailed pkgdown output in the console. Build progress, warnings, and errors are still shown. |
pandoc |
Path to the directory containing the |
Unlike a live preview, build() writes directly to your package: it updates
roxygen documentation (unless document = FALSE), renders README.Rmd to
README.md if present, and builds the site into your configured pkgdown
output folder (usually docs/). It does not upload the site anywhere;
publish that folder with your usual hosting setup.
Invisibly, an updoc_build object with package_root, site_dir,
duration, lazy, and build_log. The full build log is saved in the
current R session's temporary directory; if a build fails, the error
message includes the log path and the error condition carries it in
$build_log.
if (interactive()) { # Run from your package directory when you are ready to publish. build() }if (interactive()) { # Run from your package directory when you are ready to publish. build() }
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.
check( pkg = ".", document = TRUE, quiet = FALSE, format = c("text", "json"), error = TRUE, pandoc = getOption("updoc.pandoc", NULL) )check( pkg = ".", document = TRUE, quiet = FALSE, format = c("text", "json"), error = TRUE, pandoc = getOption("updoc.pandoc", NULL) )
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 |
quiet |
Whether to hide detailed pkgdown output. Always treated as
|
format |
Output format:
|
error |
Whether to signal an error if the build fails. Defaults to
|
pandoc |
Path to the directory containing the |
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.
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.
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) }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) }
Starts the same live preview server as serve(), then returns right away
so you can keep working in the R console. Assign the result (for example,
site <- preview()) to check status, trigger rebuilds, or stop the server
later.
preview( pkg = ".", document = TRUE, strategy = c("smart", "lazy", "full"), port = 4321, browse = interactive(), quiet = FALSE, theme = getOption("updoc.theme", "auto"), pandoc = getOption("updoc.pandoc", NULL) )preview( pkg = ".", document = TRUE, strategy = c("smart", "lazy", "full"), port = 4321, browse = interactive(), quiet = FALSE, theme = getOption("updoc.theme", "auto"), pandoc = getOption("updoc.pandoc", NULL) )
pkg |
Path to an R package (or any file or folder inside it). Defaults
to the current directory ( |
document |
Whether to re-run roxygen2 when files in |
strategy |
How to rebuild after you save a file:
|
port |
Preferred local port for the preview server (defaults to |
browse |
Whether to open the preview in your browser right away.
Defaults to |
quiet |
Whether to hide detailed pkgdown output in the console. Build progress, warnings, and errors are still shown. |
theme |
Color scheme for the in-browser status popup:
Override the default across sessions with |
pandoc |
Path to the directory containing the |
Previews build in a temporary copy of your package, leaving your man/
files, README.md, and docs/ folder untouched. Edits to README.Rmd are
rendered automatically, and if a build fails, your last working preview
stays up until you fix the error and save again.
Invisibly, an updoc_preview handle with url and package_root
fields. Print the handle to see its current status, or call its methods:
$status(): inspect build status, warnings, errors, and the
build_log file path (kept for the current R session).
$wait(timeout = 60, after = NULL): check for any newly saved changes,
wait until the preview finishes building (or until timeout seconds
pass), and return the current status. Pass after (a previous
rebuild_count) to wait until a newer build finishes or fails.
$rebuild(full = FALSE): trigger a manual rebuild (pass full = TRUE
to rebuild the entire site).
$open(): open the preview in your browser again.
$stop(): stop watching files and shut down the server.
if (interactive()) { # Run from your package directory. site <- preview() site$status() site$rebuild() # Stop the server when you are done. site$stop() }if (interactive()) { # Run from your package directory. site <- preview() site$status() site$rebuild() # Stop the server when you are done. site$stop() }
Builds your pkgdown site, opens it in your browser, and automatically
rebuilds and refreshes whenever you save a change. The R console stays busy
until you press Ctrl+C to stop the server; use preview() instead if you
want to keep using R while the preview runs.
serve( pkg = ".", document = TRUE, strategy = c("smart", "lazy", "full"), port = 4321, browse = interactive(), quiet = FALSE, theme = getOption("updoc.theme", "auto"), pandoc = getOption("updoc.pandoc", NULL) )serve( pkg = ".", document = TRUE, strategy = c("smart", "lazy", "full"), port = 4321, browse = interactive(), quiet = FALSE, theme = getOption("updoc.theme", "auto"), pandoc = getOption("updoc.pandoc", NULL) )
pkg |
Path to an R package (or any file or folder inside it). Defaults
to the current directory ( |
document |
Whether to re-run roxygen2 when files in |
strategy |
How to rebuild after you save a file:
|
port |
Preferred local port for the preview server (defaults to |
browse |
Whether to open the preview in your browser right away.
Defaults to |
quiet |
Whether to hide detailed pkgdown output in the console. Build progress, warnings, and errors are still shown. |
theme |
Color scheme for the in-browser status popup:
Override the default across sessions with |
pandoc |
Path to the directory containing the |
Previews run in a temporary copy of your package, so your man/ files,
README.md, and docs/ folder stay untouched. Use check() for a one-shot
non-destructive build check, or build() when you are ready to build the
site for publishing.
Invisibly, the stopped updoc_preview handle.
if (interactive()) { # Run from your package directory. Press Ctrl+C to stop. serve() }if (interactive()) { # Run from your package directory. Press Ctrl+C to stop. serve() }