Skip to content

Commit

Permalink
Expands meta-package support for tidymodels
Browse files Browse the repository at this point in the history
  • Loading branch information
‘topepo’ committed Jan 9, 2024
1 parent c0a8f64 commit e2c73bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# downlit (development version)

* Expands meta-package support for tidymodels (#173).

# downlit 0.4.3

* Fix for upcoming R-devel (#169).
Expand Down
9 changes: 6 additions & 3 deletions R/packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ register_attached_packages <- function(packages) {
options("downlit.attached" = union(packages, getOption("downlit.attached")))
}

meta_packages <- c("tidyverse", "tidymodels")
add_depends <- function(packages) {
if ("tidyverse" %in% packages && is_installed("tidyverse")) {
core <- getNamespace("tidyverse")$core
packages <- union(packages, core)
for (meta in meta_packages) {
if (meta %in% packages && is_installed(meta)) {
core <- getNamespace(meta)$core
packages <- union(packages, core)
}
}

# add packages attached by depends
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ test_that("adds tidyverse packages", {
skip_if_not_installed("tidyverse")
expect_true("ggplot2" %in% add_depends("tidyverse"))
})

test_that("adds tidymodels packages", {
skip_if_not_installed("tidymodels")
expect_true("tune" %in% add_depends("tidymodels"))
})

0 comments on commit e2c73bb

Please sign in to comment.