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