R/bioc-releases.R

Defines functions bioc_releases_cache wood_bioc_releases

Documented in wood_bioc_releases

#' List Bioconductor releases
#'
#' @description This function scrapes the Bioconductor site for version codes
#' of all its releases.
#'
#' @return A character vector, where each element is a Bioconductor release.
#'
#' @examplesIf !woodendesc:::is_cran_check()
#' wood_bioc_releases()
#'
#' @family bioc
#' @export
wood_bioc_releases <- function() {
  rlang::check_installed("xml2", "to list Bioconductor release codes.")

  bioc_releases_cache()
}

bioc_releases_cache <- function() {
  with_cache({
    httr2::request("https://bioconductor.org") |>
      httr2::req_url_path_append("about", "release-announcements") |>
      httr2::req_perform() |>
      httr2::resp_body_html(encoding = "UTF-8") |>
      xml2::xml_find_all("/html/body/main//table/tbody/tr/td[1]") |>
      xml2::xml_text()
  }, "releases", "bioc")
}
ErdaradunGaztea/woodendesc documentation built on Feb. 1, 2025, 2:26 a.m.