From c8a448ca80925772769b02569c2a7809d5953c9e Mon Sep 17 00:00:00 2001 From: m7pr Date: Thu, 18 Jan 2024 11:54:34 +0100 Subject: [PATCH 1/2] test for ; case --- tests/testthat/test-get_code.R | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/testthat/test-get_code.R b/tests/testthat/test-get_code.R index 32054ba58..09360c3b8 100644 --- a/tests/testthat/test-get_code.R +++ b/tests/testthat/test-get_code.R @@ -166,6 +166,17 @@ testthat::test_that("get_code returns result of length 1 for non-empty input", { testthat::expect_length(get_code(tdata1, deparse = TRUE), 1) }) +testthat::test_that("get_code does not break if code is separated by ;", { + code <- c( + "a <- 1;a <- a + 1" + ) + tdata <- eval_code(teal_data(), code) + testthat::expect_identical( + get_code(tdata, datanames = "a"), + gsub(";", "\n", code, fixed = TRUE) + ) +}) + # assign ---------------------------------------------------------------------------------------------------------- From e4187e5f3a7727cc007d2457a7d6020ddbb3e229 Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 16 Oct 2024 11:56:20 +0200 Subject: [PATCH 2/2] depreceta datanames in teal.data::get_code --- NEWS.md | 5 +++++ R/teal_data-get_code.R | 3 ++- man/get_code.Rd | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 08d441316..b7fb3b300 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,10 @@ # teal.data 0.6.0.9012 +### Deprecations + +- `get_code(datanames)` `S4` method parameter for `teal_data()` object was soft deprecated. Use `get_code(names)`. + + ### Enhancements - `datanames()` diff --git a/R/teal_data-get_code.R b/R/teal_data-get_code.R index d74435bd6..ebeda7f6a 100644 --- a/R/teal_data-get_code.R +++ b/R/teal_data-get_code.R @@ -1,6 +1,6 @@ #' Get code from `teal_data` object #' -#' Retrieve code from `teal_data` object. +#' `r lifecycle::badge("deprecated")` Retrieve code from `teal_data` object. #' #' Retrieve code stored in `@code`, which (in principle) can be used to recreate all objects found in `@env`. #' Use `datanames` to limit the code to one or more of the datasets enumerated in `@datanames`. @@ -108,6 +108,7 @@ setMethod("get_code", signature = "teal_data", definition = function(object, dep checkmate::assert_flag(deparse) code <- if (!is.null(datanames)) { + warning("get_code(datanames) was deprecated in teal.data 0.6.1, use get_code(names) instead.") get_code_dependency(object@code, datanames, ...) } else { object@code diff --git a/man/get_code.Rd b/man/get_code.Rd index 29b3a4134..09f31a755 100644 --- a/man/get_code.Rd +++ b/man/get_code.Rd @@ -24,7 +24,7 @@ Either a character string or an expression. If \code{datanames} is used to reque only code that \emph{creates} that dataset (not code that uses it) is returned. Otherwise, all contents of \verb{@code}. } \description{ -Retrieve code from \code{teal_data} object. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Retrieve code from \code{teal_data} object. } \details{ Retrieve code stored in \verb{@code}, which (in principle) can be used to recreate all objects found in \verb{@env}.