Skip to content

Commit

Permalink
improve indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
maxheld83 committed Nov 29, 2024
1 parent a0d8251 commit 77491a0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
19 changes: 13 additions & 6 deletions R/shiny2screenshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,21 @@ roxy_tag_rd.roxy_tag_crowInsertSnaps <- function(x, base_path, env) {
)
}

glue_latex <- function(..., .envir = parent.frame()) {
glue::glue(..., .envir = .envir, .open = "[", .close = "]")
}

#' @export
format.rd_section_crowInsertSnaps <- function(x, ...) {
paste0(
"\\section{Screenshots from Tests}{\n",
"\\if{html}",
paste(x$value, collapse = "\n"),
"\\if{latex}{Screenshots cannot be shown in this output format.}",
"}\n"
inner <- glue::glue_collapse(x$value, sep = "\n")

Check warning on line 219 in R/shiny2screenshot.R

View workflow job for this annotation

GitHub Actions / Test, Check, Lint and Document Package (rlint)

file=R/shiny2screenshot.R,line=219,col=3,[object_usage_linter] local variable 'inner' assigned but may not be used
glue_latex(
"\\section{Screenshots from Tests}
\\if{html}{
[inner]
}
\\if{latex}{
Screenshots cannot be shown in this output format.
}"
)
}

Expand Down
22 changes: 15 additions & 7 deletions tests/testthat/_snaps/shiny2screenshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,27 @@
Code
topic$get_section("crowInsertSnaps")
Output
\section{Screenshots from Tests}{
\if{html}{name: \code{bins}, variant: \code{linux} \figure{crow_screenshots/helpers/bins.gif}{options: width='100\%' alt=Screenshot from App}}\if{latex}{Screenshots cannot be shown in this output format.}}
\section{Screenshots from Tests}
\if{html}{
name: \code{bins}, variant: \code{linux}
}
\if{latex}{
Screenshots cannot be shown in this output format.
}

# roxy_tag_crowInsertSnaps: can be formatted with multiple tags joined

Code
topic$get_section("crowInsertSnaps")
Output
\section{Screenshots from Tests}{
\if{html}{name: \code{bins}, variant: \code{linux} \figure{crow_screenshots/helpers/bins.gif}{options: width='100\%' alt=Screenshot from App}}
{name: \code{bins}, variant: \code{mac} \figure{crow_screenshots/helpers/bins.gif}{options: width='100\%' alt=Screenshot from App}}\if{latex}{Screenshots cannot be shown in this output format.}}
\section{Screenshots from Tests}
\if{html}{
name: \code{bins}, variant: \code{linux}
name: \code{bins}, variant: \code{mac}
}
\if{latex}{
Screenshots cannot be shown in this output format.
}

# snaps2fig and friends work: writes out markdown syntax

Expand Down

0 comments on commit 77491a0

Please sign in to comment.