Skip to content

Commit

Permalink
fix: Support multiline @examplesIf again (r-lib#1641)
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Aug 2, 2024
1 parent b94b42f commit 9652d15
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/rd-examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ roxy_tag_parse.roxy_tag_examplesIf <- function(x) {
)

x$raw <- paste(
paste0("\\dontshow{if (", condition, ") withAutoprint(\\{ # examplesIf}"),
lines[-1],
"\\dontshow{\\}) # examplesIf}",
sep = "\n"
c(
paste0("\\dontshow{if (", condition, ") withAutoprint(\\{ # examplesIf}"),
lines[-1],
"\\dontshow{\\}) # examplesIf}"
),
collapse = "\n"
)

tag_examples(x)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/_snaps/rd-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
\dontshow{\}) # examplesIf}
\dontshow{if (foobar()) withAutoprint(\{ # examplesIf}
and-this
and-that
\dontshow{\}) # examplesIf}
}

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-rd-examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ test_that("@examplesIf", {
#' maybe-run-this-code
#' @examplesIf foobar()
#' and-this
#' and-that
NULL")[[1]]

expect_snapshot_output(out$get_section("examples"))
Expand Down

0 comments on commit 9652d15

Please sign in to comment.