diff --git a/DESCRIPTION b/DESCRIPTION index d37a0f02..5f0ea2c8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/NEWS.md b/NEWS.md index 9f3837d7..c198e575 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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). diff --git a/R/object-package.R b/R/object-package.R index 9f34b70c..3e8247e1 100644 --- a/R/object-package.R +++ b/R/object-package.R @@ -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, ")") diff --git a/man/roxygen2-package.Rd b/man/roxygen2-package.Rd index 574833b3..4e55cdb9 100644 --- a/man/roxygen2-package.Rd +++ b/man/roxygen2-package.Rd @@ -31,7 +31,7 @@ Authors: Other contributors: \itemize{ - \item Posit Software, PBC [copyright holder, funder] + \item Posit Software, PBC (\href{https://ror.org/03wc8by49}{ROR}) [copyright holder, funder] } } diff --git a/tests/testthat/_snaps/object-package.md b/tests/testthat/_snaps/object-package.md index 6d8469f0..d11959f5 100644 --- a/tests/testthat/_snaps/object-package.md +++ b/tests/testthat/_snaps/object-package.md @@ -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 diff --git a/tests/testthat/test-object-package.R b/tests/testthat/test-object-package.R index 72bf8bea..c2562a5c 100644 --- a/tests/testthat/test-object-package.R +++ b/tests/testthat/test-object-package.R @@ -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")) }) })