diff --git a/NEWS.md b/NEWS.md index 52fae9b0..98399dc4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # roxygen2 (development version) +* For person defintions `DESCRIPTION`, the comment argument can now contain an arbitrary number of elements, and the names of these elements are included in the resulting string representation (@jranke, #1746) + # roxygen2 7.3.3 * Package documentation now converts ROR IDs into a useful link (#1698, @maelle). diff --git a/R/object-package.R b/R/object-package.R index 3e8247e1..2b6d0ff1 100644 --- a/R/object-package.R +++ b/R/object-package.R @@ -78,7 +78,13 @@ author_desc <- function(x) { } if (length(x$comment) > 0) { - desc <- paste0(desc, " (", x$comment, ")") + desc <- paste0(desc, " (", + paste( + ifelse(nzchar(names(x$comment)), + paste0(names(x$comment), ": ", x$comment), + x$comment), + collapse = ", "), + ")") } } diff --git a/tests/testthat/test-object-package.R b/tests/testthat/test-object-package.R index c2562a5c..a2192ad0 100644 --- a/tests/testthat/test-object-package.R +++ b/tests/testthat/test-object-package.R @@ -102,3 +102,11 @@ test_that("multiple email addresses for a person are acceptable #1487", { "me \\email{one@email.me, two@email.me}" ) }) + +test_that("Arbitrary comments for a person are acceptable #1746", { + me <- person("me", comment = c(acronym = "m", "contributed X")) + expect_equal( + author_desc(unclass(me)[[1]]), + "me (acronym: m, contributed X)" + ) +})