Skip to content

Commit

Permalink
Fix override when used in as_pkgdown() (#2406)
Browse files Browse the repository at this point in the history
Fixes #2257
  • Loading branch information
dsweber2 authored Mar 11, 2024
1 parent 70495ff commit 1924ebf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#' @export
as_pkgdown <- function(pkg = ".", override = list()) {
if (is_pkgdown(pkg)) {
pkg$meta <- modify_list(pkg$meta, override)
return(pkg)
}

Expand All @@ -21,7 +22,7 @@ as_pkgdown <- function(pkg = ".", override = list()) {

desc <- read_desc(pkg)
meta <- read_meta(pkg)
meta <- utils::modifyList(meta, override)
meta <- modify_list(meta, override)

template_config <- find_template_config(
package = meta$template$package,
Expand Down
4 changes: 3 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ isFALSE <- function(x) {
}

modify_list <- function(x, y) {
if (is.null(y)) {
if (is.null(x)) {
return(y)
} else if (is.null(y)) {
return(x)
}

Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/test-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ test_that("package_vignettes() sorts articles alphabetically by file name", {
)
})

test_that("override works correctly for as_pkgdown", {
pkgdown <- as_pkgdown("assets/man-figures")
expected_list <- list(figures = list(dev = "jpeg", fig.ext = "jpg", fig.width = 3, fig.asp = 1))
expect_equal(pkgdown$meta, expected_list)
modified_pkgdown <- as_pkgdown(pkgdown, override = list(figures = list(dev = "png")))
modified_list <- list(figures = list(dev = "png", fig.ext = "jpg", fig.width = 3, fig.asp = 1))
modified_pkgdown$meta
expect_equal(modified_pkgdown$meta, modified_list)
})
# titles ------------------------------------------------------------------

test_that("multiline titles are collapsed", {
Expand Down

0 comments on commit 1924ebf

Please sign in to comment.