Skip to content

Commit 9652d15

Browse files
authored
fix: Support multiline @examplesIf again (#1641)
1 parent b94b42f commit 9652d15

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

R/rd-examples.R

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ roxy_tag_parse.roxy_tag_examplesIf <- function(x) {
1515
)
1616

1717
x$raw <- paste(
18-
paste0("\\dontshow{if (", condition, ") withAutoprint(\\{ # examplesIf}"),
19-
lines[-1],
20-
"\\dontshow{\\}) # examplesIf}",
21-
sep = "\n"
18+
c(
19+
paste0("\\dontshow{if (", condition, ") withAutoprint(\\{ # examplesIf}"),
20+
lines[-1],
21+
"\\dontshow{\\}) # examplesIf}"
22+
),
23+
collapse = "\n"
2224
)
2325

2426
tag_examples(x)

tests/testthat/_snaps/rd-examples.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
\dontshow{\}) # examplesIf}
3030
\dontshow{if (foobar()) withAutoprint(\{ # examplesIf}
3131
and-this
32+
and-that
3233
\dontshow{\}) # examplesIf}
3334
}
3435

tests/testthat/test-rd-examples.R

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ test_that("@examplesIf", {
7979
#' maybe-run-this-code
8080
#' @examplesIf foobar()
8181
#' and-this
82+
#' and-that
8283
NULL")[[1]]
8384

8485
expect_snapshot_output(out$get_section("examples"))

0 commit comments

Comments
 (0)