lifecycle

Featured

Guidance for managing R package lifecycle according to tidyverse principles using the lifecycle package. Use when: (1) Setting up lifecycle infrastructure in a package, (2) Deprecating functions or arguments, (3) Renaming functions or arguments, (4) Superseding functions, (5) Marking functions as experimental, (6) Understanding lifecycle stages (stable, experimental, deprecated, superseded), or (7) Writing deprecation helpers for complex scenarios.

DevOps & Infrastructure 474 stars 42 forks Updated 3 days ago MIT

Install

View on GitHub

Quality Score: 92/100

Stars 20%
89
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# R Package Lifecycle Management Manage function and argument lifecycle using tidyverse conventions and the lifecycle package. ## Setup Check if lifecycle is configured by looking for `lifecycle-*.svg` files in `man/figures/`. If not configured, run: ```r usethis::use_lifecycle() ``` This: - Adds lifecycle to `Imports` in DESCRIPTION - Adds `@importFrom lifecycle deprecated` to the package documentation file - Copies badge SVGs to `man/figures/` ## Lifecycle Badges Insert badges in roxygen2 documentation: ```r #' @description #' `r lifecycle::badge("experimental")` #' `r lifecycle::badge("deprecated")` #' `r lifecycle::badge("superseded")` ``` For arguments: ```r #' @param old_arg `r lifecycle::badge("deprecated")` Use `new_arg` instead. ``` Only badge functions/arguments whose stage differs from the package's overall stage. ## Deprecating a Function 1. Add badge and explanation to `@description`: ```r #' Do something #' #' @description #' `r lifecycle::badge("deprecated")` #' #' `old_fun()` was deprecated in mypkg 1.0.0. Use [new_fun()] instead. #' @keywords internal ``` 2. Add `deprecate_warn()` as first line of function body: ```r old_fun <- function(x) { lifecycle::deprecate_warn("1.0.0", "old_fun()", "new_fun()") new_fun(x) } ``` 3. Show migration in examples: ```r #' @examples #' old_fun(x) #' # -> #' new_fun(x) ``` ## Deprecation Functions | Function | When to Use | | ------------------ | ----...

Details

Author
posit-dev
Repository
posit-dev/skills
Created
9 months ago
Last Updated
3 days ago
Language
R
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category