Skip to content

More flexible syntax for warning messages #120

Description

@lionel-

The challenge is to have a flexible UI that still makes it easy to supply the metadata stored in the warning conditions, that is package, function name, and argument name.

One way to go about this is to allow a length-2 vector whose first element defines the metadata, and the second specifies a warning message.

deprecate_warn(
  "1.0.0",
  c("pkg::foo(bar)", message = "Supplying `bar = \"none\"` is deprecated.")
)
#> Warning message:
#> Supplying `bar = "none"` is deprecated.

We could use ... as a placeholder that lifecycle could fill in with generated contents.

deprecate_warn(
  "1.0.0",
  c("pkg::foo(bar)", message = "Supplying `bar = \"none\"`...")
)
#> Warning message:
#> Supplying `bar = "none"` is deprecated as of pkg 1.0.0.

deprecate_warn(
  "1.0.0",
  c("pkg::foo(bar)", message = "... can no longer be \"none\"...")
)
#> Warning message:
#> The `bar` argument of `foo()` can no longer be "none" as of pkg 1.0.0.

The with argument would also allow a message field:

deprecate_warn(
  "1.0.0",
  what = c("pkg::foo(bar)", message = "Supplying `bar = \"none\"`..."),
  with = c(message = "Please use `bar = NULL` instead.")
)
#> Warning message:
#> Supplying `bar = "none"` is deprecated as of pkg 1.0.0.
#> Please use `bar = NULL` instead.

I like that this leverages existing syntax for defining a deprecation message + metadata.

What do you think @hadley?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions