Skip to content

Commit

Permalink
Merge branch 'main' into katex-update
Browse files Browse the repository at this point in the history
  • Loading branch information
jayhesselberth authored Jan 29, 2025
2 parents ced7fdc + 74fda8c commit ccfe0d5
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 15 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Support for math rendering using katex and mathjax was improved and now includes necessary components using CDN (#2704).
* Articles (i.e., Rmarkdown/Quarto documents in `vignettes/articles`, created by `usethis::use_article()` and available on pkgdown sites but not included in a built package) have improved test cases (thanks to @venpopov and @ethanbass).
* Code repositories hosted on Codeberg are now supported in the `BugReports` and `URL` fields (@nfrerebeau, #2843).
* Articles (i.e., vignettes in `vignettes/articles`, created by `usethis::use_article()` and available on pkgdown sites but not included in a built package) have improved test cases (thanks to @venpopov and @ethanbass).
* New `clean_site(force = TRUE)` for cleaning of `docs/` regardless of whether it was built by pkgdown (#2827).
* Links to favicons in page headers were updated to reflect changes to https://realfavicongenerator.net/ (#2804). Favicons should be re-generated by manually removing the `pkgdown/favicon` directory and then running `pkgdown::build_favicons()`.
* Reinstate Rd macro loading, which was accidentally disabled in v2.1.1 (#2782).
Expand Down
9 changes: 5 additions & 4 deletions R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,15 @@
#' includes:
#' in_header: |
#' <!-- Global site tag (gtag.js) - Google Analytics -->
#' <script async src="https://www.googletagmanager.com/gtag/js?id={YOUR TRACKING ID}"#' ></script>
#' <script async src="https://www.googletagmanager.com/gtag/js?id={YOUR MEASUREMENT ID}" ></script>
#' <script>
#' window.dataLayer = window.dataLayer || [];
#' function gtag(){dataLayer.push(arguments);}
#' gtag('js', new Date());
#'
#' gtag('config', '{YOUR TRACKING ID}');
#' gtag('config', '{YOUR MEASUREMENT ID}');
#' </script>
#' <!-- Google tag (gtag.js) -->
#' ```
#' * [GoatCounter](https://www.goatcounter.com):
#'
Expand All @@ -221,8 +222,8 @@
#' of your source repository. This is used in the navbar, on the homepage,
#' in articles and reference topics, and in the changelog (to link to issue
#' numbers and user names). pkgdown can automatically figure out the necessary
#' URLs if you link to a GitHub or GitLab repo in your `BugReports` or `URL`
#' field.
#' URLs if you link to a GitHub, GitLab or Codeberg repo in your `BugReports`
#' or `URL` field.
#'
#' Otherwise, you can supply your own in the `repo` field:
#'
Expand Down
1 change: 1 addition & 0 deletions R/navbar.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ navbar_components <- function(pkg = ".") {
repo_type(pkg),
github = menu_icon("fab fa-github fa-lg", repo_home(pkg), "GitHub"),
gitlab = menu_icon("fab fa-gitlab fa-lg", repo_home(pkg), "GitLab"),
codeberg = menu_icon("fas fa-code fa-lg", repo_home(pkg), "Codeberg"),
NULL
)

Expand Down
7 changes: 5 additions & 2 deletions R/repo.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ repo_type <- function(pkg) {
"github"
} else if (grepl("^https?://gitlab\\..+/", home)) {
"gitlab"
} else if (grepl("^https?://codeberg\\..+/", home)) {
"codeberg"
} else {
"other"
}
Expand Down Expand Up @@ -75,7 +77,7 @@ package_repo <- function(pkg) {
pkg$desc$get_urls()
)

gh_links <- grep("^https?://git(hub|lab)\\..+/", urls, value = TRUE)
gh_links <- grep("^https?://(git(hub|lab)|codeberg)\\..+/", urls, value = TRUE)
if (length(gh_links) > 0) {
branch <- config_pluck_string(pkg, "repo.branch")
return(repo_meta_gh_like(gh_links[[1]], branch))
Expand All @@ -98,10 +100,11 @@ repo_meta <- function(home = NULL, source = NULL, issue = NULL, user = NULL) {
repo_meta_gh_like <- function(link, branch = NULL) {
gh <- parse_github_like_url(link)
branch <- branch %||% gha_current_branch()
blob <- if (grepl("^https?://codeberg\\.", link)) "/src/branch/" else "/blob/"

repo_meta(
paste0(gh$host, "/", gh$owner, "/", gh$repo, "/"),
paste0(gh$host, "/", gh$owner, "/", gh$repo, "/blob/", branch, "/"),
paste0(gh$host, "/", gh$owner, "/", gh$repo, blob, branch, "/"),
paste0(gh$host, "/", gh$owner, "/", gh$repo, "/issues/"),
paste0(gh$host, "/")
)
Expand Down
9 changes: 5 additions & 4 deletions man/build_site.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/deploy_site_github.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/deploy_to_branch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/init_site.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/_snaps/navbar.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# adds github/gitlab link when available
# adds github/gitlab/codeberg link when available

reference:
text: Reference
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-navbar.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test_that("adds github/gitlab link when available", {
test_that("adds github/gitlab/codeberg link when available", {
pkg <- pkg_navbar()
expect_snapshot_output(navbar_components(pkg))

Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-repo.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ test_that("can find gitlab url", {
expect_equal(package_repo(pkg), repo_meta_gh_like(url))
})

test_that("can find codeberg url", {
withr::local_envvar(GITHUB_HEAD_REF = "HEAD")
url <- "https://codeberg.org/msberends/AMR"
pkg <- local_pkgdown_site(desc = list(URL = url))
expect_equal(package_repo(pkg), repo_meta_gh_like(url))
})

test_that("uses GITHUB env vars if set", {
withr::local_envvar(GITHUB_HEAD_REF = NA, GITHUB_REF_NAME = "abc")
expect_equal(
Expand Down Expand Up @@ -172,5 +179,6 @@ test_that("repo_type detects repo type", {
expect_equal(repo_type2("https://github.r-lib.com/pkgdown"), "github")
expect_equal(repo_type2("https://gitlab.com/r-lib/pkgdown"), "gitlab")
expect_equal(repo_type2("https://gitlab.r-lib.com/pkgdown"), "gitlab")
expect_equal(repo_type2("https://codeberg.org/r-lib/pkgdown"), "codeberg")
expect_equal(repo_type2(NULL), "other")
})

0 comments on commit ccfe0d5

Please sign in to comment.