From e2c73bb0048ea6ce53db23c253c9e81376cf5c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98topepo=E2=80=99?= <‘mxkuhn@gmail.com’> Date: Tue, 9 Jan 2024 16:14:47 -0500 Subject: [PATCH] Expands meta-package support for tidymodels --- NEWS.md | 2 ++ R/packages.R | 9 ++++++--- tests/testthat/test-packages.R | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 4fc8311..33fba87 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # downlit (development version) +* Expands meta-package support for tidymodels (#173). + # downlit 0.4.3 * Fix for upcoming R-devel (#169). diff --git a/R/packages.R b/R/packages.R index e800c15..277e985 100644 --- a/R/packages.R +++ b/R/packages.R @@ -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 diff --git a/tests/testthat/test-packages.R b/tests/testthat/test-packages.R index d1e803f..3e13de1 100644 --- a/tests/testthat/test-packages.R +++ b/tests/testthat/test-packages.R @@ -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")) +})