diff --git a/R/rd-examples.R b/R/rd-examples.R index 62bec1ec..923cdeed 100644 --- a/R/rd-examples.R +++ b/R/rd-examples.R @@ -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) diff --git a/tests/testthat/_snaps/rd-examples.md b/tests/testthat/_snaps/rd-examples.md index d03f7244..8245b2e0 100644 --- a/tests/testthat/_snaps/rd-examples.md +++ b/tests/testthat/_snaps/rd-examples.md @@ -29,6 +29,7 @@ \dontshow{\}) # examplesIf} \dontshow{if (foobar()) withAutoprint(\{ # examplesIf} and-this + and-that \dontshow{\}) # examplesIf} } diff --git a/tests/testthat/test-rd-examples.R b/tests/testthat/test-rd-examples.R index a9cef2d9..12ae5672 100644 --- a/tests/testthat/test-rd-examples.R +++ b/tests/testthat/test-rd-examples.R @@ -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"))