From 9652d15221109917d46768e836eaf55e33c21633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Fri, 2 Aug 2024 14:20:57 +0200 Subject: [PATCH] fix: Support multiline `@examplesIf` again (#1641) --- R/rd-examples.R | 10 ++++++---- tests/testthat/_snaps/rd-examples.md | 1 + tests/testthat/test-rd-examples.R | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/R/rd-examples.R b/R/rd-examples.R index 62bec1ecd..923cdeed2 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 d03f72445..8245b2e04 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 a9cef2d9c..12ae56729 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"))