generated from pharmaverse/admiraltemplate
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update pkgdown.yml * Fix Rprofile EOF and lychee checks. * Update .lycheeignore * Update pkgdown.yml * Update .lycheeignore
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters