Skip to content

Commit 59de3d6

Browse files
authored
Also update \linkS4class{} in @inheritParams (#1776)
Fixes #1634
1 parent dfbf119 commit 59de3d6

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# roxygen2 (development version)
22

3+
* `@inheritParams` now correctly updates `\linkS4class{}` links when inheriting parameter documentation from other packages, converting them to absolute links (#1634).
34
* Package documentation now lists a person with both `"aut"` and `"cre"` roles in both the Maintainer and Authors sections (#1588).
45
* Markdown links now do a better job of resolving package names: the process is cached for better performance (#1724); it works with infix operators (e.g. `[%in%]`) (#1728); no longer changes the link text (#1662); and includes base packages when reporting ambiguous functions (#1725).
56
* Package documentation now uses `logo.svg` if available, falling back to `logo.png` (#1640).

R/rd-inherit.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,15 @@ tweak_links <- function(x, package) {
472472
)
473473
}
474474
}
475+
} else if (!is.null(tag) && tag == "\\linkS4class") {
476+
topic <- paste0(x[[1]], "-class")
477+
if (has_topic(topic, package)) {
478+
attr(x, "Rd_tag") <- "\\link"
479+
attr(x, "Rd_option") <- structure(
480+
paste0(package, ":", topic),
481+
Rd_tag = "TEXT"
482+
)
483+
}
475484
} else if (length(x) > 0) {
476485
x[] <- map(x, tweak_links, package = package)
477486
}

tests/testthat/test-rd-inherit.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ test_that("relative links converted to absolute", {
5757
link_to_base("\\link[foo::abbreviate]{abbr}"),
5858
"\\link[foo::abbreviate]{abbr}\n"
5959
)
60+
61+
# linkS4class converted to absolute link (#1634)
62+
link_to_methods <- function(x) {
63+
rd2text(parse_rd(x), package = "methods")
64+
}
65+
expect_equal(
66+
link_to_methods("\\linkS4class{genericFunction}"),
67+
"\\link[methods:genericFunction-class]{genericFunction}\n"
68+
)
6069
})
6170

6271
# tag parsing -------------------------------------------------------------

0 commit comments

Comments
 (0)