Skip to content
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
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Authors@R: c(
person("Peter", "Danenberg", , "pcd@roxygen.org", role = c("aut", "cph")),
person("Gábor", "Csárdi", , "csardi.gabor@gmail.com", role = "aut"),
person("Manuel", "Eugster", role = c("aut", "cph")),
person("Posit Software, PBC", role = c("cph", "fnd"))
person("Posit Software, PBC", role = c("cph", "fnd"),
comment = c(ROR = "03wc8by49"))
)
Description: Generate your Rd documentation, 'NAMESPACE' file, and
collation field using specially formatted comments. Writing
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# roxygen2 (development version)

* Package documentation now converts ROR IDs into a useful link (#1698, @maelle).

* The check for unexported S3 methods was improved, so it does not hang any more
if a largish data object is in the package (#1593, @jranke).

Expand Down
10 changes: 10 additions & 0 deletions R/object-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ author_desc <- function(x) {
}
x$comment <- x$comment[!names(x$comment) %in% "ORCID"]
}
if (has_name(x$comment, "ROR")) {
ror <- x$comment[["ROR"]]

if (grepl("https?://", ror)) {
desc <- paste0(desc, " (\\href{", ror, "}{ROR})")
} else {
desc <- paste0(desc, " (\\href{https://ror.org/", ror, "}{ROR})")
}
x$comment <- x$comment[!names(x$comment) %in% "ROR"]
}

if (length(x$comment) > 0) {
desc <- paste0(desc, " (", x$comment, ")")
Expand Down
2 changes: 1 addition & 1 deletion man/roxygen2-package.Rd

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

25 changes: 19 additions & 6 deletions tests/testthat/_snaps/object-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,30 @@
[1] "H W \\email{h@w.com} [contributor]"
Code
# ORCID comments
person_desc(comment = c(ORCID = "1234"))
person_desc(comment = c(ORCID = "0000-0003-4757-117X"))
Output
[1] "H W \\email{h@w.com} (\\href{https://orcid.org/1234}{ORCID})"
[1] "H W \\email{h@w.com} (\\href{https://orcid.org/0000-0003-4757-117X}{ORCID})"
Code
person_desc(comment = c(ORCID = "https://orcid.org/1234"))
person_desc(comment = c(ORCID = "https://orcid.org/0000-0003-4757-117X"))
Output
[1] "H W \\email{h@w.com} (\\href{https://orcid.org/1234}{ORCID})"
[1] "H W \\email{h@w.com} (\\href{https://orcid.org/0000-0003-4757-117X}{ORCID})"
Code
person_desc(comment = c(ORCID = "1234", "extra"))
person_desc(comment = c(ORCID = "0000-0003-4757-117X", "extra"))
Output
[1] "H W \\email{h@w.com} (\\href{https://orcid.org/1234}{ORCID}) (extra)"
[1] "H W \\email{h@w.com} (\\href{https://orcid.org/0000-0003-4757-117X}{ORCID}) (extra)"
Code
# ROR comments
person_desc(comment = c(ROR = "03wc8by49"))
Output
[1] "H W \\email{h@w.com} (\\href{https://ror.org/03wc8by49}{ROR})"
Code
person_desc(comment = c(ROR = "https://ror.org/03wc8by49"))
Output
[1] "H W \\email{h@w.com} (\\href{https://ror.org/03wc8by49}{ROR})"
Code
person_desc(comment = c(ROR = "03wc8by49", "extra"))
Output
[1] "H W \\email{h@w.com} (\\href{https://ror.org/03wc8by49}{ROR}) (extra)"

# useful message if Authors@R is corrupted

Expand Down
11 changes: 8 additions & 3 deletions tests/testthat/test-object-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ test_that("person turned into meaningful text", {
person_desc(role = "ctb")

"ORCID comments"
person_desc(comment = c("ORCID" = "1234"))
person_desc(comment = c("ORCID" = "https://orcid.org/1234"))
person_desc(comment = c("ORCID" = "1234", "extra"))
person_desc(comment = c("ORCID" = "0000-0003-4757-117X"))
person_desc(comment = c("ORCID" = "https://orcid.org/0000-0003-4757-117X"))
person_desc(comment = c("ORCID" = "0000-0003-4757-117X", "extra"))

"ROR comments"
person_desc(comment = c("ROR" = "03wc8by49"))
person_desc(comment = c("ROR" = "https://ror.org/03wc8by49"))
person_desc(comment = c("ROR" = "03wc8by49", "extra"))
})
})

Expand Down
Loading