forked from quarto-dev/quarto-r
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#' Run Interactive Document | ||
#' | ||
#' Run a Shiny interactive document. By default, the document will | ||
#' be rendered first and then run. If you have previously rendered | ||
#' the document, pass `render - FALSE` to skip rendering. | ||
#' | ||
#' @param input The input file to run. Should be a file with | ||
#' a `server: shiny` entry in its YAML front-matter. | ||
#' @param render Render the document before running it. | ||
#' | ||
#' @inheritParams quarto_serve | ||
#' | ||
#' @export | ||
quarto_run <- function(input, | ||
render = TRUE, | ||
port = getOption("shiny.port"), | ||
host = getOption("shiny.host", "127.0.0.1"), | ||
browse = TRUE) { | ||
|
||
# render if requested | ||
if (render) { | ||
quarto_render(input) | ||
} | ||
|
||
# build shiny args | ||
shiny_args <- list( | ||
port = port, | ||
host = host, | ||
launch.browser = browse | ||
) | ||
|
||
# we already ran quarto_render before the call to run | ||
# so disable rendering | ||
restore <- Sys.getenv("RMARKDOWN_RUN_PRERENDER", unset = NA) | ||
Sys.setenv(RMARKDOWN_RUN_PRERENDER = "0") | ||
if (!is.na(restore)) { | ||
on.exit(Sys.setenv(RMARKDOWN_RUN_PRERENDER = restore), add = TRUE) | ||
} | ||
|
||
# run the doc | ||
rmarkdown::run(input, shiny_args = shiny_args) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.