Skip to content

Commit 8882352

Browse files
committed
feat: add support for ROR in package documentation
1 parent 9652d15 commit 8882352

File tree

6 files changed

+33
-2
lines changed

6 files changed

+33
-2
lines changed

DESCRIPTION

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Authors@R: c(
77
person("Peter", "Danenberg", , "[email protected]", role = c("aut", "cph")),
88
person("Gábor", "Csárdi", , "[email protected]", role = "aut"),
99
person("Manuel", "Eugster", role = c("aut", "cph")),
10-
person("Posit Software, PBC", role = c("cph", "fnd"))
10+
person("Posit Software, PBC", role = c("cph", "fnd"),
11+
comment = c(ROR = "03wc8by49"))
1112
)
1213
Description: Generate your Rd documentation, 'NAMESPACE' file, and
1314
collation field using specially formatted comments. Writing

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# roxygen2 (development version)
22

3+
* Package documentation now converts ROR IDs into a useful link (#1698, @maelle).
4+
35
* The check for unexported S3 methods was improved, so it does not hang any more
46
if a largish data object is in the package (#1593, @jranke).
57

R/object-package.R

+10
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ author_desc <- function(x) {
6666
}
6767
x$comment <- x$comment[!names(x$comment) %in% "ORCID"]
6868
}
69+
if (has_name(x$comment, "ROR")) {
70+
ror <- x$comment[["ROR"]]
71+
72+
if (grepl("https?://", ror)) {
73+
desc <- paste0(desc, " (\\href{", ror, "}{ROR})")
74+
} else {
75+
desc <- paste0(desc, " (\\href{https://ror.org/", ror, "}{ROR})")
76+
}
77+
x$comment <- x$comment[!names(x$comment) %in% "ROR"]
78+
}
6979

7080
if (length(x$comment) > 0) {
7181
desc <- paste0(desc, " (", x$comment, ")")

man/roxygen2-package.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/object-package.md

+13
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@
2323
person_desc(comment = c(ORCID = "1234", "extra"))
2424
Output
2525
[1] "H W \\email{[email protected]} (\\href{https://orcid.org/1234}{ORCID}) (extra)"
26+
Code
27+
# ROR comments
28+
person_desc(comment = c(ROR = "03wc8by49"))
29+
Output
30+
[1] "H W \\email{[email protected]} (\\href{https://ror.org/03wc8by49}{ROR})"
31+
Code
32+
person_desc(comment = c(ROR = "https://ror.org/03wc8by49"))
33+
Output
34+
[1] "H W \\email{[email protected]} (\\href{https://ror.org/03wc8by49}{ROR})"
35+
Code
36+
person_desc(comment = c(ROR = "03wc8by49", "extra"))
37+
Output
38+
[1] "H W \\email{[email protected]} (\\href{https://ror.org/03wc8by49}{ROR}) (extra)"
2639

2740
# useful message if Authors@R is corrupted
2841

tests/testthat/test-object-package.R

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ test_that("person turned into meaningful text", {
1515
person_desc(comment = c("ORCID" = "1234"))
1616
person_desc(comment = c("ORCID" = "https://orcid.org/1234"))
1717
person_desc(comment = c("ORCID" = "1234", "extra"))
18+
19+
"ROR comments"
20+
person_desc(comment = c("ROR" = "03wc8by49"))
21+
person_desc(comment = c("ROR" = "https://ror.org/03wc8by49"))
22+
person_desc(comment = c("ROR" = "03wc8by49", "extra"))
1823
})
1924
})
2025

0 commit comments

Comments
 (0)