Skip to content

Commit

Permalink
Add support for inheriting 'note' fields (#1219)
Browse files Browse the repository at this point in the history
Fixes #1218
  • Loading branch information
pat-s authored Mar 30, 2022
1 parent 03e6913 commit 623c473
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
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)

* Add support for inheriting 'note' fields via `@inherit pkg::fun note` (@pat-s, #1218)

* Problems with the first tag in each block are now reported with the
correct line number (#1235).

Expand Down
1 change: 1 addition & 0 deletions R/rd-inherit.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ topics_process_inherit <- function(topics, env) {
topics$topo_apply(inherits("examples"), inherit_field, "examples")
topics$topo_apply(inherits("author"), inherit_field, "author")
topics$topo_apply(inherits("source"), inherit_field, "source")
topics$topo_apply(inherits("note"), inherit_field, "note")

# First inherit individual sections, then all sections.
topics$topo_apply(function(x) x$inherits_section_from(), inherit_section)
Expand Down
2 changes: 1 addition & 1 deletion R/tag-parser.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tag_inherit <- function(x) {

# Also recorded in `rd.Rmd`
all <- c("params", "return", "title", "description", "details", "seealso",
"sections", "references", "examples", "author", "source")
"sections", "references", "examples", "author", "source", "note")
if (length(fields) == 0) {
fields <- all
} else {
Expand Down
4 changes: 3 additions & 1 deletion tests/testthat/test-rd-inherit.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test_that("no options gives default values", {
block_get_tag_value(block, "inherit")$fields,
c(
"params", "return", "title", "description", "details", "seealso",
"sections", "references", "examples", "author", "source"
"sections", "references", "examples", "author", "source", "note"
)
)
})
Expand Down Expand Up @@ -575,6 +575,7 @@ test_that("can inherit all from single function", {
#' @param y y
#' @author Hadley
#' @source my mind
#' @note my note
#' @examples
#' x <- 1
foo <- function(x, y) {}
Expand All @@ -590,6 +591,7 @@ test_that("can inherit all from single function", {
expect_equal(out$get_value("examples"), rd("x <- 1"))
expect_equal(out$get_value("author"), "Hadley")
expect_equal(out$get_value("source"), "my mind")
expect_equal(out$get_value("note"), "my note")
})


Expand Down

0 comments on commit 623c473

Please sign in to comment.