Skip to content

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

Merged
merged 18 commits into from
Jul 29, 2025
Merged

Add use_r_universe_badge() #1994

merged 18 commits into from
Jul 29, 2025

Conversation

olivroy
Copy link
Contributor

@olivroy olivroy commented May 18, 2024

Closes #1883

Edit by @jennybc: I finished this off and sorted out various issues in the way that makes sense to me.

It has limitations, in the sense that it doesn't verify that the repo actually exists. It would also be great to add the r-universe installation options too.

I could add this to the badge with ui_code()

install.packages('{pkg}', repos = c('https://{org}.r-universe.dev', 'https://cloud.r-project.org'))

It worked out of the box with usethis
image

implementation considerations

  • marked it as experimental
  • requires a (github?) url in DESCRIPTION, or can probably manage with only git remote.
  • Assumes r-universe is set up (which is true for CRAN packages that have a repo link in DESCRIPTION), although it would probably be great to check if R-universe is set-up and nudge towards r-universe help, but that seems out of scope for this PR.
  • If the repo name is different than packages name, it doesn't affect the r-universe url. So rstudio/pins-r still has the
  • Doesn't currently care for a r-universe.dev link in description, (probably should though, but I didn't want the function to get too complicated)
  • Added an example for how to manually setup a r-universe badge in use_badge()

If you want, you can let me know what you think @jeroen. And you'd probably best to implement this function.

ideas

A browse_r_universe() similar to browse_github() would probably be useful and easy to implement + the badge could build on top of this.

man page preview

image

@jennybc jennybc requested a review from jeroen July 29, 2025 06:07
@jennybc
Copy link
Member

jennybc commented Jul 29, 2025

@jeroen Will you take a quick look at this? The only real question I have is about the most correct URL for the badge. I'll comment inline.

}

owner <- parse_repo_spec(repo_spec)[["owner"]]
src <- glue("https://{owner}.r-universe.dev/{pkg}/badges/version")
Copy link
Member

Choose a reason for hiding this comment

The 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:

https://{owner}.r-universe.dev/{pkg}/badges/version

Or:

https://{owner}.r-universe.dev/badges/{pkg}

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

Copy link
Member

Choose a reason for hiding this comment

The 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:

[![usethis status badge](https://r-lib.r-universe.dev/usethis/badges/version)](https://r-lib.r-universe.dev/usethis)

These examples are not great, as it stands. But I don't think showing the use `use_badge()` to create one's on R-universe badge is the most obvious usage to add here.
@@ -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
Copy link
Member

@jennybc jennybc Jul 29, 2025

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").

@jennybc jennybc merged commit 14dff76 into r-lib:main Jul 29, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Badge for r-universe?
2 participants