Skip to content
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

FR: Allow use of https://search.r-project.org refmans for autolinking #195

Open
TimTaylor opened this issue Aug 23, 2024 · 3 comments
Open
Labels
feature a feature request or enhancement

Comments

@TimTaylor
Copy link

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 to

https://search.r-project.org/R/refmans/base/html/grep.html

instead of

https://rdrr.io/r/base/grep.html

@hadley
Copy link
Member

hadley commented Aug 23, 2024

Yeah, now that pages exist we should use them.

@hadley hadley transferred this issue from r-lib/pkgdown Aug 23, 2024
@maelle
Copy link
Contributor

maelle commented Oct 8, 2024

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.

# 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

@hadley hadley added the feature a feature request or enhancement label Oct 22, 2024
@TimTaylor
Copy link
Author

FI - It doesn't look like the refmans at https://search.r-project.org/ are automatically updated at the moment so you probably want to hold fire for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants