From 9afde36592bbb39d3af46c6eece28cef41c62af1 Mon Sep 17 00:00:00 2001 From: Ben Straub Date: Fri, 20 Dec 2024 19:30:00 +0000 Subject: [PATCH] feat: #466 include all arguments; todo: figure out NA issue --- R/lifecycle_admiral.R | 31 ++++++++++++------- man/deprecate_inform.Rd | 24 +++++++++++--- tests/testthat/_snaps/lifecycle_admiral.md | 20 +++++++++--- .../testthat/_snaps/lifecycle_admiral.new.md | 30 ------------------ tests/testthat/test-lifecycle_admiral.R | 15 ++++++--- 5 files changed, 66 insertions(+), 54 deletions(-) delete mode 100644 tests/testthat/_snaps/lifecycle_admiral.new.md diff --git a/R/lifecycle_admiral.R b/R/lifecycle_admiral.R index 8c232dab..eb379a3d 100644 --- a/R/lifecycle_admiral.R +++ b/R/lifecycle_admiral.R @@ -2,14 +2,13 @@ #' #' Wrapper around `lifecycle::deprecate_soft()`. #' +#' @param when See documentation for `lifecycle::deprecate_soft()`. +#' @param what See documentation for `lifecycle::deprecate_soft()`. +#' @param with See documentation for `lifecycle::deprecate_soft()`. +#' @param details See documentation for `lifecycle::deprecate_soft()`. +#' @param id See documentation for `lifecycle::deprecate_soft()`. #' @param env See documentation for `lifecycle::deprecate_soft()`. -#' #' @param user_env See documentation for `lifecycle::deprecate_soft()`. -#' -#' @param ... See documentation for `lifecycle::deprecate_soft()` for additional argument use. -#' -#' -#' #' @return `NULL`, invisibly. #' #' @examples @@ -18,7 +17,7 @@ #' when = "1.0.0", #' what = "foo()", #' details = c( -#' # 'x = "This message will turn into a warning with release of x.y.z", +#' x = "This message will turn into a warning with release of x.y.z", #' i = "See admiral's deprecation guidance: #' https://pharmaverse.github.io/admiraldev/dev/articles/programming_strategy.html#deprecation" #' ) @@ -30,14 +29,22 @@ #' #' @export deprecate_inform <- function( + when, + what, + with = NULL, + details = NULL, + id = NULL, env = caller_env(), - user_env = caller_env(2), - ...) { + user_env = caller_env(2)) { tryCatch( lifecycle::deprecate_soft( - env = caller_env(), - user_env = caller_env(2), - ...), + when = when, + what = what, + with = with, + details = details, + id = id, + env = env, + user_env = user_env), warning = \(w) { message(conditionMessage(w)) tryInvokeRestart("muffleWarning") diff --git a/man/deprecate_inform.Rd b/man/deprecate_inform.Rd index ad62b110..13ca1020 100644 --- a/man/deprecate_inform.Rd +++ b/man/deprecate_inform.Rd @@ -4,14 +4,30 @@ \alias{deprecate_inform} \title{Deprecation with Soft Message} \usage{ -deprecate_inform(env = caller_env(), user_env = caller_env(2), ...) +deprecate_inform( + when, + what, + with = NULL, + details = NULL, + id = NULL, + env = caller_env(), + user_env = caller_env(2) +) } \arguments{ +\item{when}{See documentation for \code{lifecycle::deprecate_soft()}.} + +\item{what}{See documentation for \code{lifecycle::deprecate_soft()}.} + +\item{with}{See documentation for \code{lifecycle::deprecate_soft()}.} + +\item{details}{See documentation for \code{lifecycle::deprecate_soft()}.} + +\item{id}{See documentation for \code{lifecycle::deprecate_soft()}.} + \item{env}{See documentation for \code{lifecycle::deprecate_soft()}.} \item{user_env}{See documentation for \code{lifecycle::deprecate_soft()}.} - -\item{...}{See documentation for \code{lifecycle::deprecate_soft()} for additional argument use.} } \value{ \code{NULL}, invisibly. @@ -25,7 +41,7 @@ deprecate_inform( when = "1.0.0", what = "foo()", details = c( - # 'x = "This message will turn into a warning with release of x.y.z", + x = "This message will turn into a warning with release of x.y.z", i = "See admiral's deprecation guidance: https://pharmaverse.github.io/admiraldev/dev/articles/programming_strategy.html#deprecation" ) diff --git a/tests/testthat/_snaps/lifecycle_admiral.md b/tests/testthat/_snaps/lifecycle_admiral.md index 2d80021f..ae19f17d 100644 --- a/tests/testthat/_snaps/lifecycle_admiral.md +++ b/tests/testthat/_snaps/lifecycle_admiral.md @@ -1,17 +1,29 @@ -# lifecycle_admiral Test 1: Message is sent to user +# lifecycle_admiral Test 1: Simple message is sent to user Code example_fun(data) Message - `example_fun()` was deprecated in admiraldev 1.0.0. + `example_fun()` was deprecated in 1.0.0. + i Please use `example_fun2()` instead. + Code + example_fun(data) + Message + `example_fun()` was deprecated in 1.0.0. i Please use `example_fun2()` instead. -# lifecycle_admiral Test 2: Nicer message is sent to user +# lifecycle_admiral Test 2: Spicier message is sent to user Code example_fun(data) Message - `example_fun()` was deprecated in admiraldev 1.0.0. + `example_fun()` was deprecated in 1.0.0. + i Please use `example_fun2()` instead. + x This message will turn into a warning with release of 1.1.0 + i See admiral's deprecation guidance: https://pharmaverse.github.io/admiraldev/dev/articles/programming_strategy.html#deprecation + Code + example_fun(data) + Message + `example_fun()` was deprecated in 1.0.0. i Please use `example_fun2()` instead. x This message will turn into a warning with release of 1.1.0 i See admiral's deprecation guidance: https://pharmaverse.github.io/admiraldev/dev/articles/programming_strategy.html#deprecation diff --git a/tests/testthat/_snaps/lifecycle_admiral.new.md b/tests/testthat/_snaps/lifecycle_admiral.new.md deleted file mode 100644 index 7a2b1185..00000000 --- a/tests/testthat/_snaps/lifecycle_admiral.new.md +++ /dev/null @@ -1,30 +0,0 @@ -# lifecycle_admiral Test 1: Message is sent to user - - Code - example_fun(data) - Message - `example_fun()` was deprecated in admiraldev 1.0.0. - i Please use `example_fun2()` instead. - Code - example_fun(data) - Message - `example_fun()` was deprecated in admiraldev 1.0.0. - i Please use `example_fun2()` instead. - -# lifecycle_admiral Test 2: Nicer message is sent to user - - Code - example_fun(data) - Message - `example_fun()` was deprecated in admiraldev 1.0.0. - i Please use `example_fun2()` instead. - x This message will turn into a warning with release of 1.1.0 - i See admiral's deprecation guidance: https://pharmaverse.github.io/admiraldev/dev/articles/programming_strategy.html#deprecation - Code - example_fun(data) - Message - `example_fun()` was deprecated in admiraldev 1.0.0. - i Please use `example_fun2()` instead. - x This message will turn into a warning with release of 1.1.0 - i See admiral's deprecation guidance: https://pharmaverse.github.io/admiraldev/dev/articles/programming_strategy.html#deprecation - diff --git a/tests/testthat/test-lifecycle_admiral.R b/tests/testthat/test-lifecycle_admiral.R index 590a5952..a1198d88 100644 --- a/tests/testthat/test-lifecycle_admiral.R +++ b/tests/testthat/test-lifecycle_admiral.R @@ -1,7 +1,11 @@ ## Test 1: Message is sent to user ---- -test_that("lifecycle_admiral Test 1: Message is sent to user", { +test_that("lifecycle_admiral Test 1: Simple message is sent to user", { example_fun <- function(dataset) { - deprecate_inform("1.0.0", "example_fun()", "example_fun2()") + deprecate_inform( + when = "1.0.0", + what = "example_fun()", + with = "example_fun2()" + ) assert_data_frame(dataset, required_vars = exprs(STUDYID, USUBJID)) } @@ -18,9 +22,12 @@ test_that("lifecycle_admiral Test 1: Message is sent to user", { }) # Test 2: Nicer message is sent to user ---- -test_that("lifecycle_admiral Test 2: Nicer message is sent to user", { +test_that("lifecycle_admiral Test 2: Spicier message is sent to user", { example_fun <- function(dataset) { - deprecate_inform("1.0.0", "example_fun()", "example_fun2()", + deprecate_inform( + when = "1.0.0", + what = "example_fun()", + with = "example_fun2()", details = c( x = "This message will turn into a warning with release of 1.1.0", i = "See admiral's deprecation guidance: