usethis
usethis copied to clipboard
More accessible badges
Since usethis is the package that adds a lot of badges to READMEs, maintainers have asked us to help make those badges more accessible to screen readers.
I suspect the best way to do this is via the badge SVGs themselves.
@gaborcsardi already added this to METACRAN's badges:
library(tidyverse)
show_aria_label <- function(badge) {
badge %>%
xml2::read_xml() %>%
xml2::as_list() %>%
pluck("svg") %>%
attributes() %>%
pluck("aria-label")
}
show_aria_label("https://www.r-pkg.org/badges/version/usethis")
#> [1] "CRAN 2.1.5"
show_aria_label("https://www.r-pkg.org/badges/last-release/usethis")
#> [1] "CRAN 2021-12-09"
show_aria_label("https://cranlogs.r-pkg.org/badges/usethis")
#> [1] "CRAN downloads 270K/month"
Any badge produced via https://shields.io/ is already accessible:
show_aria_label("https://img.shields.io/github/workflow/status/r-lib/usethis/R-CMD-check?label=R-CMD-check")
#> [1] "R-CMD-check: passing"
show_aria_label("https://img.shields.io/badge/my__label-my__message-orange")
#> [1] "my_label: my_message"
The features of https://shields.io/ badges mean we can often substitute an accessible badge, even if the "native" badge is not (e.g. for GitHub or Codecov). I am about to explore that idea further in a pull request.
I've already placed requests with the lifecycle package (https://github.com/r-lib/lifecycle/issues/117) and with GitHub Actions (community post, post in Actions and Packages Feedback).
I'm going to try to do something about these:
- [ ]
use_bioc_badge()
I've reached out to Bioconductor and it looks like they can address it early in the new year. - [x]
use_cran_badge()
already handled via METACRAN - [ ]
use_github_actions_badge()
request made; will use shields.io in a PR - [x]
use_lifecycle_badge()
usethis already writes a shields.io badge; request made for the lifecycle package to update its svgs - [ ]
usethis:::use_codecov_badge()
will use shields.io in a PR
I'm not tackling these:
-
use_appveyor_badge()
-
use_circleci_badge()
-
use_travis_badge()
-
use_binder_badge()
This new article contains my analysis of where things stand:
https://usethis.r-lib.org/dev/articles/badge-accessibility.html