Skip to content

Commit 317b649

Browse files
committed
feat: add in_pkgdown_pkg() and IN_PKGDOWN_PKG
1 parent f3ec6e2 commit 317b649

6 files changed

Lines changed: 29 additions & 1 deletion

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ Config/testthat/start-first: build-article, build-quarto-article,
7575
Config/usethis/last-upkeep: 2025-09-07
7676
Encoding: UTF-8
7777
Roxygen: list(markdown = TRUE)
78-
RoxygenNote: 7.3.3
78+
RoxygenNote: 7.3.3.9000
7979
SystemRequirements: pandoc (>= 2.10.1)

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export(deploy_site_github)
132132
export(deploy_to_branch)
133133
export(fig_settings)
134134
export(in_pkgdown)
135+
export(in_pkgdown_pkg)
135136
export(init_site)
136137
export(pkgdown_print)
137138
export(pkgdown_sitrep)

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

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

5+
* New `in_pkgdown_pkg()` function and new `IN_PKGDOWN_PKG` variable, to go with
6+
`in_pkgdown()` and `IN_PKGDOWN`, but specific to the package whose site is being built (#2976).
7+
58
# pkgdown 2.2.0
69

710
* Make `build_llm_docs()` more robust to the use of old Pandoc (@nanxstats, @galachad, #2952, #2954)

R/pkgdown.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,18 @@ in_pkgdown <- function() {
1010
identical(Sys.getenv("IN_PKGDOWN"), "true")
1111
}
1212

13+
#' @rdname in_pkgdown
14+
#' @export
15+
#' @examples
16+
#' in_pkgdown("pkgdown")
17+
in_pkgdown_pkg <- function(pkg) {
18+
identical(Sys.getenv("IN_PKGDOWN_PKG"), pkg)
19+
}
20+
1321
local_envvar_pkgdown <- function(pkg, scope = parent.frame()) {
1422
withr::local_envvar(
1523
IN_PKGDOWN = "true",
24+
IN_PKGDOWN_PKG = pkg$package,
1625
LANGUAGE = pkg$lang,
1726
.local_envir = scope
1827
)

man/in_pkgdown.Rd

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-pkgdown.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
test_that("in_pkgdown_pkg() works", {
2+
expect_false(in_pkgdown())
3+
expect_false(in_pkgdown_pkg("testpackage"))
4+
5+
pkg <- local_pkgdown_site()
6+
local_envvar_pkgdown(pkg)
7+
8+
expect_true(in_pkgdown())
9+
expect_false(in_pkgdown_pkg("pkgdown"))
10+
expect_true(in_pkgdown_pkg("testpackage"))
11+
})

0 commit comments

Comments
 (0)