Skip to content

Commit

Permalink
rdrr.io links fix (#141)
Browse files Browse the repository at this point in the history
* Update pkgdown.yml

* Fix Rprofile EOF and lychee checks.

* Update .lycheeignore

* Update pkgdown.yml

* Update .lycheeignore
  • Loading branch information
galachad authored Sep 21, 2023
1 parent cd95618 commit 117d518
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,52 @@ jobs:
- name: Install package
run: renv::install(".", dependencies = "no-deps")
shell: Rscript {0}

- name: Add script to fix rdrr.io links for pharmaverse packages
uses: "DamianReeves/[email protected]"
with:
path: ./.Rprofile
write-mode: append
contents: |
tweak_rdrr_url <- function(...) {
html <- ..1
links <- xml2::xml_find_all(html, ".//a")
if (length(links) == 0) {
return(invisible())
}
hrefs <- xml2::xml_attr(links, "href")
needs_tweak <- grepl("^https://rdrr.io/pkg/", hrefs) & xml2::url_parse(hrefs)$scheme == "https"
fix_links <- function(x) {
pattern <- "/pkg/(\\w+)/man/(\\w+)\\.html"
matches <- stringr::str_match(x, pattern)
package_name <- matches[2]
function_name <- matches[3]
if (!(grepl("^admiral", package_name) || package_name %in% c("matatools", "matacore"))) {
return(x)
}
sprintf("https://pharmaverse.github.io/%s/main/reference/%s.html", package_name, function_name)
}
if (any(needs_tweak)) {
purrr::walk2(
links[needs_tweak],
purrr::map(hrefs[needs_tweak], fix_links),
xml2::xml_set_attr,
attr = "href"
)
}
invisible()
}
setHook("UserHook::admiralci::tweak_page", tweak_rdrr_url)
print("Tweak rdrr.io links for admiral pharmaverse packages.")
- name: Publish documentation
run: |
Expand Down
2 changes: 2 additions & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ https://packagemanager.posit.co/cran/2022-03-10/
https://packagemanager.posit.co/cran/2023-03-15/
https://packagemanager.posit.co/cran/2023-04-20/
https://packagemanager.posit.co/cran/latest
https://pharmaverse.github.io/%s/main/reference/%s.html
https://rdrr.io/pkg/

0 comments on commit 117d518

Please sign in to comment.