tools/build-site.R

Sys.setenv(NOT_CRAN = "true", DEBUG = "true")

agents_path <- "AGENTS.md"
hidden_agents_path <- ".AGENTS.md.pkgdown-hidden"

if (file.exists("README.Rmd")) {
  devtools::load_all(quiet = TRUE)

  rmarkdown::render(
    input = "README.Rmd",
    output_options = list(html_preview = FALSE),
    quiet = TRUE,
    envir = new.env(parent = globalenv())
  )
}

if (file.exists("README_en.Rmd")) {
  rmarkdown::render(
    input = "README_en.Rmd",
    output_options = list(html_preview = FALSE),
    quiet = TRUE,
    envir = new.env(parent = globalenv())
  )
}

restore_agents <- function() {
  if (file.exists(hidden_agents_path) && !file.exists(agents_path)) {
    file.rename(hidden_agents_path, agents_path)
  }
}

if (file.exists(agents_path)) {
  ok <- file.rename(agents_path, hidden_agents_path)

  if (!ok) {
    stop("Failed to hide AGENTS.md before building the site.", call. = FALSE)
  }
}

tryCatch(
  {
    pkgdown::init_site()
    pkgdown::build_site(
      preview = FALSE,
      devel = TRUE,
      lazy = TRUE,
      install = TRUE
    )
  },
  finally = restore_agents()
)

unlink("docs/AGENTS.html")
unlink("docs/dev/AGENTS.html")
unlink("docs/AGENTS.md")
unlink("docs/dev/AGENTS.md")

Try the jiebaRS package in your browser

Any scripts or data that you put into this service are public.

jiebaRS documentation built on Dec. 3, 2026, 5:09 p.m.