Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ Config/testthat/start-first: build-article, build-quarto-article,
Config/usethis/last-upkeep: 2025-09-07
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.3
RoxygenNote: 7.3.3.9000
SystemRequirements: pandoc (>= 2.10.1)
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export(deploy_site_github)
export(deploy_to_branch)
export(fig_settings)
export(in_pkgdown)
export(in_pkgdown_pkg)
export(init_site)
export(pkgdown_print)
export(pkgdown_sitrep)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

* do not autolink code that is in a link (href) in Rd files (#2972)

* New `in_pkgdown_pkg()` function and new `IN_PKGDOWN_PKG` variable, to go with
`in_pkgdown()` and `IN_PKGDOWN`. Returns/contains the name of the package
whose site is being built (#2976).

# pkgdown 2.2.0

* Make `build_llm_docs()` more robust to the use of old Pandoc (@nanxstats, @galachad, #2952, #2954)
Expand Down
10 changes: 10 additions & 0 deletions R/pkgdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ in_pkgdown <- function() {
identical(Sys.getenv("IN_PKGDOWN"), "true")
}

#' @rdname in_pkgdown
#' @param pkg Package name (a string)
#' @export
#' @examples
#' in_pkgdown_pkg("pkgdown")
in_pkgdown_pkg <- function(pkg) {
identical(Sys.getenv("IN_PKGDOWN_PKG"), pkg)
}

local_envvar_pkgdown <- function(pkg, scope = parent.frame()) {
withr::local_envvar(
IN_PKGDOWN = "true",
IN_PKGDOWN_PKG = pkg$package,
LANGUAGE = pkg$lang,
.local_envir = scope
)
Expand Down
7 changes: 7 additions & 0 deletions man/in_pkgdown.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/testthat/test-pkgdown.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test_that("in_pkgdown_pkg() works", {
expect_false(in_pkgdown())
expect_false(in_pkgdown_pkg("testpackage"))

pkg <- local_pkgdown_site()
local_envvar_pkgdown(pkg)

expect_true(in_pkgdown())
expect_false(in_pkgdown_pkg("pkgdown"))
expect_true(in_pkgdown_pkg("testpackage"))
})