Skip to content

Commit 1ab432d

Browse files
committed
add test and fix for untested thing 🫠
1 parent 916d01b commit 1ab432d

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

R/build-llm.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,14 @@ create_absolute_links <- function(main_html, pkg) {
7474
if (pkg$development$in_dev && pkg$bs_version > 3) {
7575
url <- paste0(url, pkg$prefix)
7676
}
77-
a_external <- a[!grepl("external-link", xml2::xml_attr(a, "class"))]
77+
a_internal <- a[
78+
!startsWith(xml2::xml_attr(a, "href"), "https") &
79+
!startsWith(xml2::xml_attr(a, "href"), "#")
80+
]
7881

79-
href_absolute <- xml2::url_absolute(xml2::xml_attr(a_external, "href"), url)
82+
href_absolute <- xml2::url_absolute(xml2::xml_attr(a_internal, "href"), url)
8083
href_absolute <- path_ext_set(href_absolute, "md")
84+
xml2::xml_attr(a_internal, "href") <- href_absolute
8185
}
8286
xml2::xml_attr(a, "class") <- NULL
8387
}

tests/testthat/_snaps/build-llm/llm.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ GitHub repository from the package (e.g. with
3131
[`usethis::use_github()`](https://usethis.r-lib.org/reference/use_github.html)),
3232
and file an issue with a link to the repository.
3333

34+
pkgdown is designed to make it quick and easy to build a website for
35+
your package. You can see pkgdown in action at
36+
<https://pkgdown.r-lib.org>: this is the output of pkgdown applied to
37+
the latest version of pkgdown. Learn more in
38+
[`vignette("pkgdown")`](https:/pkgdown.r-lib.org/articles/pkgdown.md) or
39+
[`?build_site`](https:/pkgdown.r-lib.org/reference/build_site.md).
40+
3441
------------------------------------------------------------------------
3542

3643
1. Note that dots (`.`) in the package name need to be replaced by

tests/testthat/assets/llm.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,11 @@
3434
</div>
3535
<div class
3636

37+
<p>pkgdown is designed to make it quick and easy to build a website for your package.
38+
You can see pkgdown in action at <a href="https://pkgdown.r-lib.org" class="uri">https://pkgdown.r-lib.org</a>:
39+
this is the output of pkgdown applied to the latest version of pkgdown.
40+
Learn more in <code><a href="articles/pkgdown.html">vignette("pkgdown")</a></code>
41+
or <code><a href="reference/build_site.html">?build_site</a></code>.</p>
42+
43+
3744
</main>

tests/testthat/test-build-llm.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ test_that("build_llm_docs() works", {
1919
test_that("convert_md() works", {
2020
skip_if_no_pandoc()
2121
pkg <- local_pkgdown_site()
22+
pkg$meta$url <- "https://pkgdown.r-lib.org"
2223

2324
dir <- withr::local_tempdir()
2425
pkg$dst_path <- dir

0 commit comments

Comments
 (0)