Skip to content

Commit ace81d3

Browse files
authored
feat: add support for ROR in package documentation (#1699)
* feat: add support for ROR in package documentation * fix: adapt the code to ORCID ID checking in R devel
1 parent 9652d15 commit ace81d3

File tree

6 files changed

+42
-11
lines changed

6 files changed

+42
-11
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 10 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/object-package.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,30 @@
1212
[1] "H W \\email{[email protected]} [contributor]"
1313
Code
1414
# ORCID comments
15-
person_desc(comment = c(ORCID = "1234"))
15+
person_desc(comment = c(ORCID = "0000-0003-4757-117X"))
1616
Output
17-
[1] "H W \\email{[email protected]} (\\href{https://orcid.org/1234}{ORCID})"
17+
[1] "H W \\email{[email protected]} (\\href{https://orcid.org/0000-0003-4757-117X}{ORCID})"
1818
Code
19-
person_desc(comment = c(ORCID = "https://orcid.org/1234"))
19+
person_desc(comment = c(ORCID = "https://orcid.org/0000-0003-4757-117X"))
2020
Output
21-
[1] "H W \\email{[email protected]} (\\href{https://orcid.org/1234}{ORCID})"
21+
[1] "H W \\email{[email protected]} (\\href{https://orcid.org/0000-0003-4757-117X}{ORCID})"
2222
Code
23-
person_desc(comment = c(ORCID = "1234", "extra"))
23+
person_desc(comment = c(ORCID = "0000-0003-4757-117X", "extra"))
2424
Output
25-
[1] "H W \\email{[email protected]} (\\href{https://orcid.org/1234}{ORCID}) (extra)"
25+
[1] "H W \\email{[email protected]} (\\href{https://orcid.org/0000-0003-4757-117X}{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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ test_that("person turned into meaningful text", {
1212
person_desc(role = "ctb")
1313

1414
"ORCID comments"
15-
person_desc(comment = c("ORCID" = "1234"))
16-
person_desc(comment = c("ORCID" = "https://orcid.org/1234"))
17-
person_desc(comment = c("ORCID" = "1234", "extra"))
15+
person_desc(comment = c("ORCID" = "0000-0003-4757-117X"))
16+
person_desc(comment = c("ORCID" = "https://orcid.org/0000-0003-4757-117X"))
17+
person_desc(comment = c("ORCID" = "0000-0003-4757-117X", "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)