Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

override is ignored in as_pkgdown() on pkgdown objects #2257

Closed
Bisaloo opened this issue Dec 19, 2022 · 2 comments · Fixed by #2406
Closed

override is ignored in as_pkgdown() on pkgdown objects #2257

Bisaloo opened this issue Dec 19, 2022 · 2 comments · Fixed by #2406
Labels
bug an unexpected problem or unintended behavior

Comments

@Bisaloo
Copy link
Contributor

Bisaloo commented Dec 19, 2022

Reprex

td <- tempfile("testpkg")

usethis::create_package(td)
#> ✔ Creating '/tmp/RtmpgHN77D/testpkg6642792d7bf9/'
#> ✔ Setting active project to '/tmp/RtmpgHN77D/testpkg6642792d7bf9'
#> ✔ Creating 'R/'
#> ✔ Writing 'DESCRIPTION'
#> Package: testpkg6642792d7bf9
#> Title: What the Package Does (One Line, Title Case)
#> Version: 0.0.0.9000
#> Authors@R (parsed):
#>     * First Last <[email protected]> [aut, cre] (YOUR-ORCID-ID)
#> Description: What the package does (one paragraph).
#> License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a
#>     license
#> Encoding: UTF-8
#> Roxygen: list(markdown = TRUE)
#> RoxygenNote: 7.2.3
#> ✔ Writing 'NAMESPACE'
#> ✔ Setting active project to '<no active project>'

p <- pkgdown::as_pkgdown(td)

p_es <- pkgdown::as_pkgdown(p, override = list(lang = "es"))

identical(p, p_es)
#> [1] TRUE

p_es$meta$lang
#> NULL

Created on 2022-12-19 with reprex v2.0.2.9000

Use case

I'm trying to override parameters in build_site_github_pages(). But the pkg argument is converted to a pkgdown object before passing it to build_site(), where the override argument should be used. As a result, the override argument is silently ignored.

Using build_site() directly may be a better choice for this use case but it's still confusing that an argument gets ignored without warning or message.

@maelle maelle added the bug an unexpected problem or unintended behavior label Sep 29, 2023
hadley pushed a commit that referenced this issue Mar 11, 2024
@dshemetov
Copy link

I don't think this is fully fixed in #2406. as_pkgdown(pkg, override), if pkg = ".", computes a lot of top level attribute variables that are used downstream that don't live in pkg$meta, such as destination and dst_path. Before #2406, if is_pkg(pkg) was true, as_pkgdown(pkg, override) would just return pkg. With #2406, we modify pkg$meta <- modify_list(pkg$meta, override), but this doesn't recompute the downstream attributes. This leads to an instance where version_label does not get properly overwritten with this code with pkgdown==2.0.9

# _pkgdown.yml
development:
  mode: devel
  version_label: success

# Code
r$> Sys.setenv("PKGDOWN_DEV_MODE" = "release")
r$> override = list(development = list(mode = "release", version_label = "light"))
r$> pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE, override=override)

So a bit more work needs to be done to go through the rest of the as_pkgdown() code and tease out which attributes need to be recomputed if meta changes.

@dshemetov
Copy link

For a less general solution that targets only build_site_github_pages(), we could merge an override arguments in the dots with list(destination = dest_dir) and feed that to the initial call of as_pkgdown(). See here.

SebKrantz pushed a commit to SebKrantz/pkgdown that referenced this issue Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants