## ----not-cran-check, include = FALSE------------------------------------------
# Skip code evaluation on CRAN (external API calls will fail)
not_cran_check <- identical(Sys.getenv("NOT_CRAN"), "true") &&
  !nzchar(Sys.getenv("_R_CHECK_PACKAGE_NAME_"))
run_vignette <- isTRUE(getOption("pkgdown.in_progress")) || not_cran_check
knitr::opts_chunk$set(eval = run_vignette, purl = run_vignette)
# Inline `r` code runs even when chunks are skipped (eval = FALSE), so
# values computed in chunks go through this helper. `expr` is only
# evaluated when the chunks ran, and falls back if it cannot be computed.
inline_value <- function(expr, fallback = "n/a") {
  if (!run_vignette) {
    return(fallback)
  }
  tryCatch(expr, error = function(e) fallback)
}

