Skip to content

Commit 2827626

Browse files
authored
Get @example working with R6 (#1821)
Fixes #1158
1 parent 4f77fdf commit 2827626

6 files changed

Lines changed: 6 additions & 2 deletions

File tree

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* R6 improvements:
66
* The "Super classes" section now omits the `pkg::` prefix for parent classes from the same package, making the inheritance chain easier to read (#1567).
77
* R6 classes with only active bindings and `cloneable = FALSE` no longer error during documentation (#1610).
8+
* `@example` (singular, with a file path) now works correctly in R6 class documentation (#1158).
89
* Inherited method links now only link to parent classes that have documentation, avoiding broken links when parent classes are undocumented (#963, #1155).
910
* `initialize()` method parameters now automatically inherit documentation from `@field` tags with the same name, reducing the need to duplicate descriptions. Explicit `@param` tags still take precedence (#1004).
1011
* New `needs_roxygenize()` provides a lightweight check that man pages are up-to-date by comparing modification times of `.Rd` files with their source files (#1411).

R/rd-r6.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
topic_add_r6_methods <- function(rd, block, env) {
1+
topic_add_r6_methods <- function(rd, block, env, base_path) {
22
docs <- r6_class_from_block(block, env)
33

44
# Add class-level tags

R/rd.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ block_to_rd.roxy_block_r6class <- function(block, base_path, env) {
219219
return()
220220
}
221221

222-
topic_add_r6_methods(rd, block, env)
222+
topic_add_r6_methods(rd, block, env, base_path)
223223

224224
describe_rdname <- topic_add_describe_in(rd, block, env)
225225
filename <- describe_rdname %||%

tests/testthat/_snaps/rd-r6.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
Method 2 details.
2323
}
2424
\examples{
25+
a <- A$new()
2526
## Example for meth1
2627
## Example for meth2
2728

tests/testthat/testR6/R/classes.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#' Class A details
88
#'
99
#' @param Z zzzzzzz
10+
#' @example example.R
1011

1112
A <- R6::R6Class(
1213
"A",

tests/testthat/testR6/example.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a <- A$new()

0 commit comments

Comments
 (0)