generated from pharmaverse/admiraltemplate
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: #466 deprecate 2.0 * docs: #466 unit tests and roxygen * chore: #466 news * chore: #466 pkgdown yml * Update vignettes/programming_strategy.Rmd Co-authored-by: Stefan Bundfuss <[email protected]> * Update vignettes/programming_strategy.Rmd Co-authored-by: Stefan Bundfuss <[email protected]> * Update vignettes/programming_strategy.Rmd Co-authored-by: Stefan Bundfuss <[email protected]> * Update vignettes/programming_strategy.Rmd Co-authored-by: Stefan Bundfuss <[email protected]> * Update vignettes/programming_strategy.Rmd Co-authored-by: Stefan Bundfuss <[email protected]> * feat: #466 inform function skeleton and tests * feat: looking at snapshot options with lifecycle * docs: #466 news entry for function and some general guidance for reference page * docs: #466 inserted details in guidance * docs: #466 feedback from review * docs: #466 more feedback adopted from review * docs: #466 lets read! * chore: #466 that lintr life * chore: #466 making it work again * chore: #466 style me baby!! * chore: #466 lints and docs * chore: #446 unclear on doc updates * docs: #466 wordsmithing fun for deprecation!! * chore: #466 styling and spelling * chore: #466 docs * chore: #466 namespace * feat: #466 arguments from lifecycle for environments * chore: #466 argument hell * feat: #466 include all arguments; todo: figure out NA issue * docs: #466 getting pretty; environment tweaks * documentation udpate * doc update * doc update * chore: #466 spelling * Update admiraldev.Rproj --------- Co-authored-by: Stefan Bundfuss <[email protected]> Co-authored-by: Daniel Sjoberg <[email protected]>
- Loading branch information
1 parent
6a074e3
commit c0e266f
Showing
10 changed files
with
328 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#' Deprecation with Soft Message | ||
#' | ||
#' Wrapper around `lifecycle::deprecate_soft()` that messages users about | ||
#' deprecated features and functions instead of warning. | ||
#' | ||
#' @inheritParams lifecycle::deprecate_soft | ||
#' | ||
#' @return `NULL`, invisibly. | ||
#' | ||
#' @examples | ||
#' # A Phase 1 deprecated function with custom bulleted list: | ||
#' deprecate_inform( | ||
#' when = "1.0.0", | ||
#' what = "foo()", | ||
#' details = c( | ||
#' 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" | ||
#' ) | ||
#' ) | ||
#' | ||
#' @keywords messages | ||
#' @family messages | ||
#' | ||
#' | ||
#' @export | ||
deprecate_inform <- function( | ||
when, | ||
what, | ||
with = NULL, | ||
details = NULL, | ||
id = NULL, | ||
env = rlang::caller_env(), | ||
user_env = rlang::caller_env(2)) { | ||
tryCatch( | ||
lifecycle::deprecate_soft( | ||
when = when, | ||
what = what, | ||
with = with, | ||
details = details, | ||
id = id, | ||
env = env, | ||
user_env = user_env | ||
), | ||
warning = \(w) { | ||
message(conditionMessage(w)) | ||
tryInvokeRestart("muffleWarning") | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# lifecycle_admiral Test 1: Simple 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: Spicier 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
## 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( | ||
when = "1.0.0", | ||
what = "example_fun()", | ||
with = "example_fun2()" | ||
) | ||
assert_data_frame(dataset, required_vars = exprs(STUDYID, USUBJID)) | ||
} | ||
|
||
data <- dplyr::tribble( | ||
~STUDYID, ~USUBJID, | ||
"xyz", 123, | ||
"xyz", 456 | ||
) | ||
|
||
expect_snapshot({ | ||
example_fun(data) | ||
example_fun(data) | ||
}) | ||
}) | ||
|
||
# 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( | ||
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: | ||
https://pharmaverse.github.io/admiraldev/dev/articles/programming_strategy.html#deprecation" # nolint | ||
) | ||
) | ||
assert_data_frame(dataset, required_vars = exprs(STUDYID, USUBJID)) | ||
} | ||
|
||
data <- dplyr::tribble( | ||
~STUDYID, ~USUBJID, | ||
"xyz", 123, | ||
"xyz", 456 | ||
) | ||
|
||
expect_snapshot({ | ||
example_fun(data) | ||
example_fun(data) | ||
}) | ||
}) |
Oops, something went wrong.