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 Mar 2, 2025
2 parents 68d48f4 + d061677 commit 6d685fd
Show file tree
Hide file tree
Showing 23 changed files with 103 additions and 56 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Authors@R: c(
person("Olivier", "Roy", role = "aut"),
person("Salim", "Brüggemann", role = "aut",
comment = c(ORCID = "0000-0002-5329-5987")),
person("Posit Software, PBC", role = c("cph", "fnd"))
person("Posit Software, PBC", role = c("cph", "fnd"),
comment = c(ROR = "03wc8by49"))
)
Description: Generate an attractive and useful website from a source
package. 'pkgdown' converts your documentation, vignettes, 'README',
Expand Down Expand Up @@ -73,5 +74,5 @@ Config/testthat/parallel: true
Config/testthat/start-first: build-article, build-quarto-article, build-reference
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
RoxygenNote: 7.3.2.9000
SystemRequirements: pandoc
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 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).
* pkgdown now uses the same Sass variables as bslib to set the navbar background color: `$navbar-bg` for the background color in light and dark mode, or `$navbar-light-bg` and `$navbar-dark-bg` for individually controlling light and dark mode background colors. `pkgdown-navbar-bg` and `$pkgdown-navbar-bg-dark` both still provide pkgdown-specific overrides (@gadenbuie, #2847).
* 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).
* Articles (i.e., Rmd/qmd files 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
31 changes: 28 additions & 3 deletions R/build-home-authors.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ data_home_sidebar_authors <- function(pkg = ".", call = caller_env()) {
)
data <- data_authors(pkg, roles)
authors <- purrr::map_chr(data$main, author_desc, comment = FALSE)

before <- config_pluck_markdown_inline(pkg, "authors.sidebar.before", call = call)
after <- config_pluck_markdown_inline(pkg, "authors.sidebar.after", call = call)

bullets <- c(before, authors, after)
if (data$needs_page) {
bullets <- c(bullets, a(tr_("More about authors..."), "authors.html"))
Expand Down Expand Up @@ -136,11 +136,15 @@ author_list <- function(x, authors_info = NULL, comment = FALSE, pkg = ".") {
orcid <- purrr::pluck(x$comment, "ORCID")
x$comment <- remove_orcid(x$comment)

ror <- purrr::pluck(x$comment, "ROR")
x$comment <- remove_ror(x$comment)

list(
name = name,
roles = roles,
comment = linkify(x$comment),
orcid = orcid_link(orcid)
orcid = orcid_link(orcid),
ror = ror_link(ror)
)
}

Expand All @@ -151,6 +155,9 @@ author_desc <- function(x, comment = TRUE) {
if (!is.null(x$orcid)) {
x$orcid
},
if (!is.null(x$ror)) {
x$ror
},
if (comment && !is.null(x$comment) && length(x$comment) != 0) {
paste0("<br/>\n<small>(", linkify(x$comment), ")</small>")
}
Expand All @@ -168,6 +175,17 @@ orcid_link <- function(orcid) {
)
}

ror_link <- function(ror) {
if (is.null(ror)) {
return(NULL)
}

paste0(
"<a href='https://ror.org/", ror, "'>",
"<img src='https://raw.githubusercontent.com/ror-community/ror-logos/main/ror-icon-rgb.svg' class='ror' alt='ROR'></a>"
)
}

# Derived from:
# db <- utils:::MARC_relator_db
# db <- db[db$usage != "",]
Expand Down Expand Up @@ -300,3 +318,10 @@ remove_orcid <- function(x) {
}
out
}
remove_ror <- function(x) {
out <- x[names2(x) != "ROR"]
if (all(names(out) == "")) {
names(out) <- NULL
}
out
}
9 changes: 6 additions & 3 deletions R/build-home.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@
#' See `?build_home` and `?build_site` for details about changing the location
#' of the authors information within the home sidebar and the site footer.
#'
#' ## Authors ORCID and bio
#' ## Authors ORCID, ROR and bio
#'
#' Author ORCID identification numbers in the `DESCRIPTION` are linked using
#' the ORCID logo:
#' the ORCID logo,
#' author ROR identification numbers are linked using the ROR logo:
#'
#' ```r
#' Authors@R: c(
Expand All @@ -131,7 +132,9 @@
#' ),
#' person("Jay", "Hesselberth", role = "aut",
#' comment = c(ORCID = "0000-0002-6299-179X")
#' )
#' ),
#' person("Posit Software, PBC", role = c("cph", "fnd"),
#' comment = c(ROR = "03wc8by49"))
#' )
#' ```
#'
Expand Down
11 changes: 6 additions & 5 deletions R/repo.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ package_repo <- function(pkg) {
# Use metadata if available
repo <- config_pluck_list(pkg, "repo")
url <- config_pluck_list(pkg, "repo.url")


if (!is.null(url)) {
return(repo)
}

# Otherwise try and guess from `BugReports` (1st priority) and `URL`s (2nd priority)
urls <- c(
sub("/issues/?", "/", pkg$desc$get_field("BugReports", default = character())),
sub("(/-)?/issues/?", "/", pkg$desc$get_field("BugReports", default = character())),
pkg$desc$get_urls()
)

Expand Down Expand Up @@ -101,11 +101,12 @@ 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/"
issues <- if (grepl("^https?://gitlab\\.", link)) "/-/issues/" else "/issues/"

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, "/issues/"),
paste0(gh$host, "/", gh$owner, "/", gh$repo, issues),
paste0(gh$host, "/")
)
}
Expand All @@ -116,13 +117,13 @@ gha_current_branch <- function() {
if (ref != "") {
return(ref)
}

# Set everywhere but might not be a branch
ref <- Sys.getenv("GITHUB_REF_NAME")
if (ref != "") {
return(ref)
}

"HEAD"
}

Expand Down
13 changes: 9 additions & 4 deletions inst/BS5/assets/pkgdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $pkgdown-navbar-bg-dark: if($navbar-dark-bg, $navbar-dark-bg, null) !default;
}

// make both the active nav and the hovered nav more clear by mixing the
// background colour with the body and primary colours respectively
// background colour with the body and primary colours respectively
.nav-item .nav-link {
@include border-radius($border-radius);
}
Expand Down Expand Up @@ -312,6 +312,11 @@ dt:target + dd {
color: #A6CE39;
margin-right: 4px;
}
// ror badge
.ror {
height: 16px;
margin-right: 4px;
}
// activate font awesome
.fab {
font-family: "Font Awesome 5 Brands" !important;
Expand Down Expand Up @@ -372,7 +377,7 @@ a[href='#main'] {
}
.lifecycle-stable { background-color: rgb(16, 128, 1); color: var(--bs-white);}
.lifecycle-superseded { background-color: rgb(7, 64, 128); color: var(--bs-white);}
.lifecycle-experimental,
.lifecycle-experimental,
.lifecycle-deprecated { background-color: rgb(253, 128, 8); color: var(--bs-black);}

/* Footnotes ---------------------------------------------------------------- */
Expand Down Expand Up @@ -452,7 +457,7 @@ pre, pre code {
// Default dark mode styling does not look good for code
[data-bs-theme="dark"] {
pre, code {
background-color: RGBA(var(--bs-body-color-rgb), 0.1);
background-color: RGBA(var(--bs-body-color-rgb), 0.1);
}
// don't double apply transparency
pre code {
Expand Down Expand Up @@ -594,7 +599,7 @@ span.smallcaps {font-variant: small-caps;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}

Expand Down
2 changes: 1 addition & 1 deletion inst/BS5/templates/content-authors.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h1>{{{pagetitle}}}</h1>
<ul class="list-unstyled">
{{#authors}}
<li>
<p><strong>{{{name}}}</strong>. {{{roles}}}. {{{orcid}}}
<p><strong>{{{name}}}</strong>. {{{roles}}}. {{{orcid}}}{{{ror}}}
{{#comment}}<br /><small>{{{.}}}</small>{{/comment}}</p>
</li>
{{/authors}}
Expand Down
2 changes: 1 addition & 1 deletion inst/BS5/templates/content-citation-authors.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h2>{{#translate}}{{authors}}{{/translate}}</h2>
<ul class="list-unstyled">
{{#authors}}
<li>
<p><strong>{{{name}}}</strong>. {{{roles}}}. {{{orcid}}}
<p><strong>{{{name}}}</strong>. {{{roles}}}. {{{orcid}}}{{{ror}}}
{{#comment}}<br /><small>{{{.}}}</small>{{/comment}}</p>
</li>
{{/authors}}
Expand Down
2 changes: 1 addition & 1 deletion inst/BS5/templates/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{{#has_favicons}}
<!-- favicons -->
<link rel="icon" type="image/png" sizes="48x48" href="{{#site}}{{root}}{{/site}}favicon-48x48.png">
<link rel="icon" type="image/png" sizes="96x96" href="{{#site}}{{root}}{{/site}}favicon-96x96.png">
<link rel="icon" type=”image/svg+xml” href="{{#site}}{{root}}{{/site}}favicon.svg">
<link rel="apple-touch-icon" sizes="180x180" href="{{#site}}{{root}}{{/site}}apple-touch-icon.png">
<link rel="icon" sizes="any" href="{{#site}}{{root}}{{/site}}favicon.ico" >
Expand Down
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 man/pkgdown-package.Rd

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

4 changes: 2 additions & 2 deletions man/test-dont.Rd

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

Binary file removed pkgdown/favicon/favicon-48x48.png
Binary file not shown.
Binary file added pkgdown/favicon/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/favicon.ico
Binary file not shown.
16 changes: 0 additions & 16 deletions tests/testthat/_snaps/build-article.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,6 @@

<span class="co">## <span style="color: #BB0000;">X</span></span>

# build_article yields useful error if pandoc fails

Code
build_article("test", pkg, pandoc_args = "--fail-if-warnings")
Message
Reading vignettes/test.Rmd
Condition
Error in `build_article()`:
! Failed to render 'vignettes/test.Rmd'.
x [WARNING] This document format requires a nonempty <title> element.
x Defaulting to 'test.knit' as the title.
x To specify a title, use 'title' in metadata or --metadata title="...".
x Failing because there were warnings.
Caused by error:
! pandoc document conversion failed with error 3

# build_article yields useful error if R fails

Code
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/build-home-authors.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<ul class='list-unstyled'>
<li>BEFORE</li>
<li>Jo Doe <br />
<small class = 'roles'> Author, maintainer </small> </li>
<small class = 'roles'> Author, maintainer </small> </li>
<li>AFTER</li>
</ul>
</div>
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/_snaps/build-home-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<h2 data-toc-skip>Developers</h2>
<ul class='list-unstyled'>
<li>Jo Doe <br />
<small class = 'roles'> Author, maintainer </small> </li>
<small class = 'roles'> Author, maintainer </small> </li>
</ul>
</div>
Expand All @@ -80,8 +80,8 @@
<div class="developers">
<h2 data-toc-skip>Developers</h2>
<ul class="list-unstyled">
<li>Hadley Wickham <br><small class="roles"> Author, maintainer </small> </li>
<li>RStudio <br><small class="roles"> Copyright holder, funder </small> </li>
<li>Hadley Wickham <br><small class="roles"> Author, maintainer </small> </li>
<li>RStudio <br><small class="roles"> Copyright holder, funder </small> </li>
<li><a href="authors.html">More about authors...</a></li>
</ul>
</div>
Expand Down
11 changes: 8 additions & 3 deletions tests/testthat/test-build-article.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,16 @@ test_that("build_article yields useful error if pandoc fails", {
skip_if_no_pandoc("2.18")

pkg <- local_pkgdown_site()
pkg <- pkg_add_file(pkg, "vignettes/test.Rmd", "Hi")
pkg <- pkg_add_file(pkg, "vignettes/test.Rmd", c(
"Some text.",
"",
"[^1]: Unreferenced footnote.",
""
))

expect_snapshot(
expect_error(
build_article("test", pkg, pandoc_args = "--fail-if-warnings"),
error = TRUE
"Note with key .+ defined at .+ but not used"
)
})

Expand Down
21 changes: 21 additions & 0 deletions tests/testthat/test-build-home-authors.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ test_that("ORCID can be identified & removed from all comment styles", {
)
})

test_that("ROR can be identified & removed from all comment styles", {
desc <- desc::desc(text = c(
'Authors@R: c(',
' person("no comment"),',
' person("bare comment", comment = "comment"),',
' person("ror only", comment = c(ROR = "1")),',
' person("both", comment = c("comment", ROR = "2"))',
' )'
))
authors <- purrr::map(desc$get_authors(), author_list, list())
expect_equal(
purrr::map(authors, "ror"),
list(NULL, NULL, ror_link("1"), ror_link("2"))
)

expect_equal(
purrr::map(authors, "comment"),
list(character(), "comment", character(), "comment")
)
})

test_that("author comments linkified with escaped angle brackets (#2127)", {
p <- list(name = "Jane Doe", roles = "rev", comment = "<https://x.org/>")
expect_match(
Expand Down
Loading

0 comments on commit 6d685fd

Please sign in to comment.