Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lifecycle deprecation badges/warnings #867

Merged
merged 5 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repos:
- methods
- checkmate
- htmltools
- lifecycle
- stats
- stringi
- id: use-tidy-description
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Depends:
Imports:
checkmate (>= 2.1.0),
htmltools (>= 0.5.4),
lifecycle (>= 0.2.0),
stats,
stringi (>= 1.6)
Suggests:
Expand All @@ -44,7 +45,6 @@ Suggests:
dplyr (>= 1.0.5),
flextable (>= 0.8.4),
knitr (>= 1.42),
lifecycle (>= 0.2.0),
officer (>= 0.5.0),
r2rtf (>= 0.3.2),
rmarkdown (>= 2.19),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ importFrom(formatters,export_as_pdf)
importFrom(formatters,export_as_txt)
importFrom(htmltools,tagList)
importFrom(htmltools,tags)
importFrom(lifecycle,deprecated)
importFrom(magrittr,"%>%")
importFrom(stats,binom.test)
importFrom(stats,na.omit)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

### Miscellaneous
* Removed deprecated functions `add_analyzed_var` and `trim_zero_rows`.
* Added `lifecycle` badge files for documentation.
* Deprecated the `gap` and `check_headers` arguments to `rbindl_rtables` using `lifecycle`.

## rtables 0.6.6
### New Features
Expand Down
17 changes: 12 additions & 5 deletions R/colby_constructors.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ setGeneric(

#' @rdname int_methods
setMethod("split_rows", "NULL", function(lyt, spl, pos, cmpnd_fun = AnalyzeMultiVars) {
.Deprecated(msg = "Initializing layouts via NULL is deprecated, please use basic_table() instead")
lifecycle::deprecate_warn(
when = "0.3.8",
what = I("split_rows(NULL)"),
with = "basic_table()",
details = "Initializing layouts via `NULL` is no longer supported."
)
rl <- PreDataRowLayout(SplitVector(spl))
cl <- PreDataColLayout()
PreDataTableLayouts(rlayout = rl, clayout = cl)
Expand Down Expand Up @@ -208,10 +213,12 @@ setGeneric(

#' @rdname int_methods
setMethod("split_cols", "NULL", function(lyt, spl, pos) {
.Deprecated(msg = paste(
"Initializing layouts via NULL is deprecated,",
"please use basic_table() instead"
))
lifecycle::deprecate_warn(
when = "0.3.8",
what = I("split_cols(NULL)"),
with = "basic_table()",
details = "Initializing layouts via `NULL` is no longer supported."
)
cl <- PreDataColLayout(SplitVector(spl))
rl <- PreDataRowLayout()
PreDataTableLayouts(rlayout = rl, clayout = cl)
Expand Down
1 change: 1 addition & 0 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' @importFrom utils head head.matrix tail tail.matrix
#' @importFrom stats setNames na.omit prop.test binom.test relevel quantile
#' @importFrom htmltools tags tagList
#' @importFrom lifecycle deprecated
#' @importFrom magrittr %>%
#' @import methods
NULL
16 changes: 8 additions & 8 deletions R/tree_accessors.R
Original file line number Diff line number Diff line change
Expand Up @@ -3001,10 +3001,10 @@ setGeneric("col_fnotes_here", function(obj) standardGeneric("col_fnotes_here"))
#' @export
#' @rdname ref_fnotes
setMethod("col_fnotes_here", "ANY", function(obj) {
.Deprecated(
new = "col_footnotes",
old = "col_fnotes_here",
msg = "col_fnotes_here was deprecated in {rtables} version 0.6.5.9011. Please use col_footnotes instead."
lifecycle::deprecate_warn(
when = "0.6.6",
what = "col_fnotes_here()",
with = "col_footnotes()"
)
col_footnotes(obj)
})
Expand All @@ -3016,10 +3016,10 @@ setGeneric("col_fnotes_here<-", function(obj, value) standardGeneric("col_fnotes
#' @export
#' @rdname int_methods
setMethod("col_fnotes_here<-", "ANY", function(obj, value) {
.Deprecated(
new = "col_footnotes<-",
old = "col_fnotes_here<-",
msg = "col_fnotes_here<- was deprecated in {rtables} version 0.6.5.9011. Please use col_footnotes<- instead."
lifecycle::deprecate_warn(
when = "0.6.6",
what = I("col_fnotes_here()<-"),
with = I("col_footnotes()<-")
)
col_footnotes(obj) <- value
})
Expand Down
33 changes: 23 additions & 10 deletions R/tt_compatibility.R
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,18 @@ only_first_annot <- function(all_annots) {
#' @rdname rbind
#' @aliases rbind
#' @export
rbindl_rtables <- function(x, gap = 0, check_headers = TRUE) {
if (!check_headers) {
warning("check_headers = FALSE is no longer supported, ignoring.")
rbindl_rtables <- function(x, gap = lifecycle::deprecated(), check_headers = lifecycle::deprecated()) {
if (lifecycle::is_present(gap)) {
lifecycle::deprecate_warn(
when = "0.3.2",
what = "rbindl_rtables(gap)"
)
}
if (lifecycle::is_present(check_headers)) {
lifecycle::deprecate_warn(
when = "0.3.2",
what = "rbindl_rtables(check_headers)"
)
}

firstcols <- col_info(x[[1]])
Expand Down Expand Up @@ -507,7 +516,7 @@ rbindl_rtables <- function(x, gap = 0, check_headers = TRUE) {
setMethod(
"rbind", "VTableNodeInfo",
function(..., deparse.level = 1) {
rbindl_rtables(list(...), check_headers = TRUE)
rbindl_rtables(list(...))
}
)

Expand All @@ -530,7 +539,7 @@ setMethod(
setMethod(
"rbind2", "VTableNodeInfo",
function(x, y) {
rbindl_rtables(list(x, y), check_headers = TRUE)
rbindl_rtables(list(x, y))
}
)

Expand Down Expand Up @@ -926,7 +935,9 @@ chk_compat_cinfos <- function(tt1, tt2) {
}


#' **Deprecated:** Insert `rrow`s at (before) a specific location
#' Insert `rrow`s at (before) a specific location
#'
#' `r lifecycle::badge("deprecated")`
#'
#' This function is deprecated and will be removed in a future release of `rtables`. Please use
#' [insert_row_at_path()] or [label_at_path()] instead.
Expand Down Expand Up @@ -973,7 +984,11 @@ chk_compat_cinfos <- function(tt1, tt2) {
#' @export
insert_rrow <- function(tbl, rrow, at = 1,
ascontent = FALSE) {
.Deprecated("insert_row_at_path or label_at_path(tab)<-", old = "insert_rrow")
lifecycle::deprecate_warn(
when = "0.4.0",
what = "insert_rrow()",
with = I("insert_row_at_path() or label_at_path()")
)
stopifnot(
is(tbl, "VTableTree"),
is(rrow, "TableRow"),
Expand All @@ -985,9 +1000,7 @@ insert_rrow <- function(tbl, rrow, at = 1,
}

if (at == 1) {
return(rbindl_rtables(list(rrow, tbl),
check_headers = TRUE
))
return(rbindl_rtables(list(rrow, tbl)))
} else if (at == nrow(tbl) + 1) {
return(rbind2(tbl, rrow))
}
Expand Down
2 changes: 1 addition & 1 deletion R/tt_dotabulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ recursive_applysplit <- function(df,
#'
#' @inheritParams gen_args
#' @inheritParams lyt_args
#' @param col_counts (`numeric` or `NULL`)\cr `r lifecycle::badge("deprecated")` if non-`NULL`, column counts
#' @param col_counts (`numeric` or `NULL`)\cr if non-`NULL`, column counts
#' which override those calculated automatically during tabulation. Must specify "counts" for *all*
#' resulting columns if non-`NULL`. `NA` elements will be replaced with the automatically calculated counts.
#' @param col_total (`integer(1)`)\cr the total observations across all columns. Defaults to `nrow(df)`.
Expand Down
2 changes: 1 addition & 1 deletion man/build_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions man/figures/lifecycle-archived.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-defunct.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-deprecated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-experimental.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-maturing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-questioning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions man/figures/lifecycle-soft-deprecated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions man/figures/lifecycle-stable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading