Skip to content

Commit

Permalink
Support template.bslib.version but throw if template.bootstrap is…
Browse files Browse the repository at this point in the history
… also set
  • Loading branch information
gadenbuie committed Feb 22, 2024
1 parent 0b51097 commit bbd6191
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ as_pkgdown <- function(pkg = ".", override = list()) {
meta <- read_meta(pkg)
meta <- utils::modifyList(meta, override)

bs_version <- get_bootstrap_version(list(meta = meta))

template_config <- find_template_config(
package = meta$template$package,
bs_version = meta$template$bootstrap
bs_version = bs_version
)
meta <- modify_list(template_config, meta)

Expand All @@ -37,8 +39,6 @@ as_pkgdown <- function(pkg = ".", override = list()) {
package <- desc$get_field("Package")
version <- desc$get_field("Version")

bs_version <- check_bootstrap_version(meta$template$bootstrap, pkg)

development <- meta_development(meta, version, bs_version)

if (is.null(meta$destination)) {
Expand Down Expand Up @@ -97,6 +97,28 @@ read_desc <- function(path = ".") {
desc::description$new(path)
}

get_bootstrap_version <- function(pkg) {
template_bootstrap <- pkg$meta[["template"]]$bootstrap
template_bslib <- pkg$meta[["template"]]$bslib$version

if (!is.null(template_bootstrap) && !is.null(template_bslib)) {
cli::cli_abort(
c(
sprintf(
"Both {.field %s} and {.field %s} are set.",
pkgdown_field(pkg, c("template", "bootstrap")),
pkgdown_field(pkg, c("template", "bslib", "version"))
),
x = "Remove one of them from {.file {pkgdown_config_relpath(pkg)}}"
),
call = caller_env()
)
}

version <- template_bootstrap %||% template_bslib
check_bootstrap_version(version, pkg)
}

check_bootstrap_version <- function(version, pkg) {
if (is.null(version)) {
3
Expand Down

0 comments on commit bbd6191

Please sign in to comment.