| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/app_template.R |
| 3 |
\name{shinyAppTemplate} |
| 4 |
\alias{shinyAppTemplate} |
| 5 |
\title{Generate a Shiny application from a template} |
| 6 |
\usage{ |
| 7 |
shinyAppTemplate(path = NULL, examples = "default", dryrun = FALSE) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{path}{Path to create new shiny application template.} |
| 11 |
|
| 12 |
\item{examples}{Either one of "default", "ask", "all", or any combination of |
| 13 |
"app", "rdir", "module", and "tests". In an |
| 14 |
interactive session, "default" falls back to "ask"; in a non-interactive |
| 15 |
session, "default" falls back to "all". With "ask", this function will |
| 16 |
prompt the user to select which template items will be added to the new app |
| 17 |
directory. With "all", all template items will be added to the app |
| 18 |
directory.} |
| 19 |
|
| 20 |
\item{dryrun}{If \code{TRUE}, don't actually write any files; just print out which |
| 21 |
files would be written.} |
| 22 |
} |
| 23 |
\description{ |
| 24 |
This function populates a directory with files for a Shiny application. |
| 25 |
} |
| 26 |
\details{ |
| 27 |
In an interactive R session, this function will, by default, prompt the user |
| 28 |
to select which components to add to the application. Choices are |
| 29 |
|
| 30 |
\if{html}{\out{<div class="sourceCode">}}\preformatted{1: All |
| 31 |
2: app.R : Main application file |
| 32 |
3: R/example.R : Helper file with R code |
| 33 |
4: R/example-module.R : Example module |
| 34 |
5: tests/testthat/ : Tests using the testthat and shinytest2 package |
| 35 |
}\if{html}{\out{</div>}} |
| 36 |
|
| 37 |
If option 1 is selected, the full example application including the |
| 38 |
following files and directories is created: |
| 39 |
|
| 40 |
\if{html}{\out{<div class="sourceCode">}}\preformatted{appdir/ |
| 41 |
|- app.R |
| 42 |
|- R |
| 43 |
| |- example-module.R |
| 44 |
| `- example.R |
| 45 |
`- tests |
| 46 |
|- testthat.R |
| 47 |
`- testthat |
| 48 |
|- setup-shinytest2.R |
| 49 |
|- test-examplemodule.R |
| 50 |
|- test-server.R |
| 51 |
|- test-shinytest2.R |
| 52 |
`- test-sort.R |
| 53 |
}\if{html}{\out{</div>}} |
| 54 |
|
| 55 |
Some notes about these files: |
| 56 |
\itemize{ |
| 57 |
\item \code{app.R} is the main application file. |
| 58 |
\item All files in the \verb{R/} subdirectory are automatically sourced when the |
| 59 |
application is run. |
| 60 |
\item \code{R/example.R} and \code{R/example-module.R} are automatically sourced when |
| 61 |
the application is run. The first contains a function \code{lexical_sort()}, |
| 62 |
and the second contains code for module created by the |
| 63 |
\code{\link[=moduleServer]{moduleServer()}} function, which is used in the application. |
| 64 |
\item \verb{tests/} contains various tests for the application. You may |
| 65 |
choose to use or remove any of them. They can be executed by the |
| 66 |
\code{\link[=runTests]{runTests()}} function. |
| 67 |
\item \code{tests/testthat.R} is a test runner for test files in the |
| 68 |
\verb{tests/testthat/} directory using the |
| 69 |
\href{https://rstudio.github.io/shinytest2/reference/test_app.html}{shinytest2} |
| 70 |
package. |
| 71 |
\item \code{tests/testthat/setup-shinytest2.R} is setup file to source your \code{./R} folder into the testing environment. |
| 72 |
\item \code{tests/testthat/test-examplemodule.R} is a test for an application's module server function. |
| 73 |
\item \code{tests/testthat/test-server.R} is a test for the application's server code |
| 74 |
\item \code{tests/testthat/test-shinytest2.R} is a test that uses the |
| 75 |
\href{https://rstudio.github.io/shinytest2/}{shinytest2} package to do |
| 76 |
snapshot-based testing. |
| 77 |
\item \code{tests/testthat/test-sort.R} is a test for a supporting function in the \verb{R/} directory. |
| 78 |
} |
| 79 |
} |