Skip to content

Can data_color provide a deprecation message through lifecycle or rlang? #1160

@mrcaseb

Description

@mrcaseb

gt/R/data_color.R

Lines 567 to 584 in e263689

if (is.character(rlang::eval_tidy(fn))) {
palette <- rlang::eval_tidy(fn)
fn <- NULL
cli::cli_warn(c(
"Since gt v0.9.0, the `colors` argument has been deprecated.",
"*" = "Please use the `palette` argument to define a color palette."
))
} else {
cli::cli_warn(c(
"Since gt v0.9.0, the `colors` argument has been deprecated.",
"*" = "Please use the `fn` argument instead."
))
}

gt 0.9.0 deprecates the colors argument in data_color and prints the warning on every call.

Can this be changed to a "once every 8 hours" deprecation warning?

It's possible to do this with either lifcycle (which is a reverse dependency through ggplot2) or by passing .frequency and .frequency_id arguments in the cli_warning like

cli::cli_warn(
  c(
    "Since gt v0.9.0, the `colors` argument has been deprecated.",
    "*" = "Please use the `palette` argument to define a color palette."
  ), 
  .frequency = "regularly",
  .frequency_id = "data_color_warning"
)
#> Warning: Since gt v0.9.0, the `colors` argument has been deprecated.
#> • Please use the `palette` argument to define a color palette.
#> This warning is displayed once every 8 hours.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions