r-lib / usethis

Set up commonly used 📦 components
https://usethis.r-lib.org/
Other
861 stars 285 forks source link

More accessible badges #1554

Open jennybc opened 2 years ago

jennybc commented 2 years ago

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

jennybc commented 2 years ago

I'm going to try to do something about these:

I'm not tackling these:

jennybc commented 2 years ago

This new article contains my analysis of where things stand:

https://usethis.r-lib.org/dev/articles/badge-accessibility.html