Skip to content

Commit 30b69ce

Browse files
committed
Implement use_lifecycle_badge
Fixes #48
1 parent b44ae43 commit 30b69ce

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export(use_github)
3838
export(use_github_labels)
3939
export(use_github_links)
4040
export(use_gpl3_license)
41+
export(use_lifecycle_badge)
4142
export(use_mit_license)
4243
export(use_namespace)
4344
export(use_news_md)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# usethis 1.0.0.9000
22

3+
* New `use_lifecycle_badge()` (#48).
4+
35
* New `use_cc0_license()`, which is particularly appropriate for data packages
46
(#94)
57

R/badge.R

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,50 @@ use_depsy_badge <- function() {
3636
invisible(TRUE)
3737
}
3838

39+
40+
#' Create a life cycle badge
41+
#'
42+
#' * Experimental: very early days, a lot of churn in search of a good API.
43+
#' Not on CRAN. Might not go anywhere. Use with care.
44+
#' * Maturing: API roughed out, but finer details likely to change. Will strive
45+
#' to maintain backward compatibility, but need wider usage in order to get
46+
#' more feedback.
47+
#' * Dormant: not currently working on it, but plan to come back to in the
48+
#' future.
49+
#' * Stable: we're happy with the API, and the unlikely to be major changes.
50+
#' Backward incompatible changes will only be made if absolutely critical, and
51+
#' will be accompanied by a change in the major version.
52+
#' * Questioning: no long convinced this is a good approach, but don't yet
53+
#' know what a better approach might be.
54+
#' * Retired: known better replacement available elsewhere. Will remain
55+
#' available on CRAN.
56+
#' * Archived: development complete. Archived on CRAN and on GitHub.
57+
#'
58+
#' @param stage Stage of the lifecycle. See description above.
59+
#' @export
60+
use_lifecycle_badge <- function(stage) {
61+
62+
stage <- match.arg(tolower(stage), names(stages))
63+
colour <- stages[[stage]]
64+
65+
url <- paste0(
66+
"https://img.shields.io/badge/lifecycle-", stage, "-", colour, ".svg"
67+
)
68+
69+
use_badge("lifecycle", url, url)
70+
}
71+
72+
stages <- c(
73+
experimental = "orange",
74+
maturing = "blue",
75+
stable = "brightgreen",
76+
retired = "orange",
77+
archived = "red",
78+
dormant = "blue",
79+
questioning = "blue"
80+
)
81+
82+
3983
#' Use a README badge
4084
#'
4185
#' @param badge_name Badge name. Used in error message and alt text

man/use_lifecycle_badge.Rd

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)