-
Notifications
You must be signed in to change notification settings - Fork 289
Add use_r_universe_badge()
#1994
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
Changes from all commits
f19a833
9e97e35
fbca4c8
e157ca8
a397f9c
a47ba4a
efbf7ff
5f52463
5088288
13cd6e7
878f18c
8e0a995
c9ce04f
ba09502
bb2e349
c3e5d1d
136b57c
f4e648b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
inst/doc | ||
docs | ||
internal | ||
|
||
/.quarto/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,23 @@ | |
#' available on CRAN, powered by <https://www.r-pkg.org> | ||
#' * `use_lifecycle_badge()`: badge declares the developmental stage of a | ||
#' package according to <https://lifecycle.r-lib.org/articles/stages.html>. | ||
#' * `use_r_universe_badge()`: `r lifecycle::badge("experimental")` badge | ||
#' indicates what version of your package is available on [R-universe | ||
#' ](https://r-universe.dev/search/). It is assumed that you have already | ||
#' completed the | ||
#' [necessary R-universe setup](https://docs.r-universe.dev/publish/set-up.html). | ||
#' * `use_binder_badge()`: badge indicates that your repository can be launched | ||
#' in an executable environment on <https://mybinder.org/> | ||
#' * `use_posit_cloud_badge()`: badge indicates that your repository can be launched | ||
#' in a [Posit Cloud](https://posit.cloud) project | ||
#' * `use_rscloud_badge()`: `r lifecycle::badge("deprecated")`: Use | ||
#' * `use_rscloud_badge()`: `r lifecycle::badge("deprecated")` Use | ||
#' [use_posit_cloud_badge()] instead. | ||
#' | ||
#' @param badge_name Badge name. Used in error message and alt text | ||
#' @param href,src Badge link and image src | ||
#' @param stage Stage of the package lifecycle. One of "experimental", | ||
#' "stable", "superseded", or "deprecated". | ||
#' @eval param_repo_spec() | ||
#' @seealso [use_github_action()] helps with the setup of various continuous | ||
#' integration workflows, some of which will call these specialized badge | ||
#' helpers. | ||
|
@@ -144,6 +150,35 @@ use_binder_badge <- function(ref = git_default_branch(), urlpath = NULL) { | |
|
||
invisible(TRUE) | ||
} | ||
#' @rdname badges | ||
#' @export | ||
use_r_universe_badge <- function(repo_spec = NULL) { | ||
check_is_package("use_r_universe_badge()") | ||
pkg <- project_name() | ||
|
||
if (is.null(repo_spec)) { | ||
this_env <- current_call() | ||
tryCatch( | ||
github_url <- github_url(), | ||
error = function(e) { | ||
ui_abort( | ||
c( | ||
"x" = "Can't determine the R-universe owner of the {.pkg {pkg}} package.", | ||
"!" = "No GitHub URL found in DESCRIPTION or the Git remotes.", | ||
"i" = "Update the project configuration or provide an explicit {.arg repo_spec}." | ||
), | ||
call = this_env | ||
) | ||
} | ||
) | ||
repo_spec <- parse_repo_url(github_url)[["repo_spec"]] | ||
} | ||
|
||
owner <- parse_repo_spec(repo_spec)[["owner"]] | ||
src <- glue("https://{owner}.r-universe.dev/{pkg}/badges/version") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't tell if the best form is what I currently have:
Or:
It feels like the prose and the example here sort of contradict each other? https://docs.r-universe.dev/publish/set-up.html#badge-showing-the-number-of-the-deployed-version There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also the markdown you get from the "copy markdown" button on a page like this: https://r-lib.r-universe.dev/badges looks like:
|
||
href <- glue("https://{owner}.r-universe.dev/{pkg}") | ||
use_badge("R-universe version", href, src) | ||
} | ||
|
||
#' @rdname badges | ||
#' @param url A link to an existing [Posit Cloud](https://posit.cloud) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm: it's "R-universe" (lowercase "u"), yeah? As opposed to "R-Universe" (uppercase "U").