Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for ROR #2851

Merged
merged 5 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# pkgdown (development version)

* 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).
* pkgdown now transforms ROR IDs in `DESCRIPTION` into icons, like it already did for ORCID IDs. (#2850)

** 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).
* New `clean_site(force = TRUE)` for cleaning of `docs/` regardless of whether it was built by pkgdown (#2827).
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 <- 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 @@
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 @@
if (!is.null(x$orcid)) {
x$orcid
},
if (!is.null(x$ror)) {
x$ror

Check warning on line 159 in R/build-home-authors.R

View check run for this annotation

Codecov / codecov/patch

R/build-home-authors.R#L159

Added line #L159 was not covered by tests
},
if (comment && !is.null(x$comment) && length(x$comment) != 0) {
paste0("<br/>\n<small>(", linkify(x$comment), ")</small>")
}
Expand All @@ -168,6 +175,17 @@
)
}

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>"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the version with transparent background?

https://github.com/ror-community/ror-logos/blob/main/ror-icon-rgb-transparent.svg

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it look worse in dark mode?

)
}

# Derived from:
# db <- utils:::MARC_relator_db
# db <- db[db$usage != "",]
Expand Down Expand Up @@ -300,3 +318,10 @@
}
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
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;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it should be bigger

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

16px seems like a fine place to start

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 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.

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
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