Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always use withAutoprint #1582

Merged
merged 8 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
titles](https://roxygen2.r-lib.org/articles/index-crossref.html) now support
Markdown syntax (#1608, @salim-b).

* `@examplesIf` always uses `withAutoprint()` (@MichaelChirico, #1581). The raw Rd
will be cleaner, but such examples will now only run under R>=3.4.0 (2017).

# roxygen2 7.3.2

* `@includeRmd` now additionally sets `options(cli.hyperlink = FALSE)` to make
Expand Down
12 changes: 4 additions & 8 deletions R/rd-examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ roxy_tag_parse.roxy_tag_examplesIf <- function(x) {
}
)

dontshow <- paste0(
"\\dontshow{if (",
condition,
") (if (getRversion() >= \"3.4\") withAutoprint else force)(\\{ # examplesIf}"
)

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

tag_examples(x)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/rd-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
# @examplesIf

\examples{
\dontshow{if (foo::bar()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
\dontshow{if (foo::bar()) withAutoprint(\{ # examplesIf}
maybe-run-this-code
\dontshow{\}) # examplesIf}
\dontshow{if (foobar()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
\dontshow{if (foobar()) withAutoprint(\{ # examplesIf}
and-this
\dontshow{\}) # examplesIf}
}
Expand Down
Loading