Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove duplicated authors #1333

Merged
merged 3 commits into from
Apr 20, 2022
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
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ S3method(format,rd_section_usage)
S3method(format,rd_section_value)
S3method(format,roxy_tag)
S3method(merge,rd_section)
S3method(merge,rd_section_author)
S3method(merge,rd_section_inherit)
S3method(merge,rd_section_inherit_dot_params)
S3method(merge,rd_section_inherit_section)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@

* `@includeRmd` is now adapted to change in rmarkdown 2.12 regarding math support in `github_document()` (#1304).

* Authors are now only counted only once if mentioned in merged documentations (@DanChaltiel #1333).

# roxygen2 7.1.2

* The new `@examplesIf` tag can be used to create conditional
Expand Down
7 changes: 7 additions & 0 deletions R/rd-markdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ roxy_tag_rd.roxy_tag_author <- function(x, base_path, env) {
format.rd_section_author <- function(x, ...) {
format_collapse(x, ...)
}
#' @export
merge.rd_section_author <- function(x, y, ...) {
stopifnot(identical(class(x), class(y)))
# Remove duplicated authors, e.g. when using @rdname
rd_section(x$type, unique(c(x$value, y$value)))
}


#' @export
roxy_tag_parse.roxy_tag_format <- function(x) tag_markdown(x)
Expand Down
20 changes: 20 additions & 0 deletions tests/testthat/test-rd-markdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ test_that("generic keys produce expected output", {
expect_equal(out$get_value("author"), "test")
})


test_that("author duplicated get removed", {
out <- roc_proc_text(rd_roclet(), "
#' @name a
#' @title a
#' @author A
NULL

#' @name b
#' @rdname a
#' @author A
NULL

#' @name c
#' @rdname a
#' @author B
NULL")[[1]]
expect_equal(out$get_value("author"), c("A", "B"))
})

test_that("@format overrides defaults", {
out <- roc_proc_text(rd_roclet(), "
#' Title
Expand Down