Open TimTaylor opened 3 months ago
Yeah, now that pages exist we should use them.
I am here to plug yet another alternative to rdrrr.io: R-universe by @jeroen. For packages that are not base R packages, that is.
For CRAN packages the manual is at https://cran.r-universe.dev/%7Bpkg%7D/doc/manual.html#{topic}
for instance https://cran.r-universe.dev/pkgdown/doc/manual.html#build_site (obviously for that package there's a pkgdown website :joy: )
Same idea for Bioconductor packages https://bioc.r-universe.dev/packages
For any package it is possible to search whether it is on R-universe, for instance:
# is babelquarto on R-universe
name <- "babelquarto"
package <- httr2::request("https://r-universe.dev/api/search") |>
httr2::req_url_query(q = sprintf('package:%s', "babelquarto")) |>
httr2::req_perform() |>
httr2::resp_body_json()
str(package, max.level = 1)
#> List of 5
#> $ results:List of 1
#> $ query :List of 1
#> $ skip : int 0
#> $ limit : int 100
#> $ total : int 1
# fortunately there is only one package with that name
# what universe
universe <- package$results[[1]]$`_user`
# topics
package_info <- httr2::request(
sprintf(
"https://%s.r-universe.dev/api/packages/%s",
universe, name
)
)|>
httr2::req_perform() |>
httr2::resp_body_json()
# so an URL is
# although probably no need to use the API to find what topic a function belongs to
topic <- "render_book"
topic_info <- purrr::keep(package_info$`_help`, \(x) topic %in% x$topics)
if (length(topic_info) == 1) {
sprintf(
"https://%s.r-universe.dev/%s/doc/manual.html#%s",
universe, name, topic_info[[1]]$page
)
}
#> [1] "https://ropensci.r-universe.dev/babelquarto/doc/manual.html#render"
Created on 2024-10-08 with reprex v2.1.0
Would you consider allowing users to specify the use of the help pages at https://search.r-project.org as opposed to https://rdrr.io/ (or perhaps any arbitrary alternative)?
E.g. it would be nice if we could make
grep()
documentation linked tohttps://search.r-project.org/R/refmans/base/html/grep.html
instead of
https://rdrr.io/r/base/grep.html