Skip to content

Commit 0320364

Browse files
authored
Update shiny apps section (#117)
1 parent b65df9d commit 0320364

File tree

2 files changed

+77
-12
lines changed

2 files changed

+77
-12
lines changed

index.Rmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ knitr::write_bib(c(
129129
[reviewers slack channel]: https://community-bioc.slack.com/archives/C02A1B8HUHZ
130130
[rmarkdown]: http://rmarkdown.rstudio.com/
131131
[rmarkdown documentation]: http://rmarkdown.rstudio.com/authoring_pandoc_markdown.html#citations
132-
[shiny-rstudio]: https://shiny.rstudio.com/
132+
[shiny-posit]: https://shiny.posit.co/
133+
[shiny-modules]: https://shiny.posit.co/r/articles/improve/modules/
133134
[software-pkgs]: https://bioconductor.org/packages/release/bioc/
134135
[support site]: https://support.bioconductor.org/
135136
[support-register]: https://support.bioconductor.org/accounts/signup/

shiny-apps.Rmd

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Shiny apps {#shiny}
22

3-
[Shiny apps][shiny-rstudio] can be submitted to _Bioconductor_ as software packages or as documented and tested functions within packages.
3+
[Shiny apps][shiny-posit] can be submitted to _Bioconductor_ as software packages or as documented and tested functions within packages.
44

55
## Code organisation
66

@@ -14,6 +14,9 @@ Shiny apps submitted to _Bioconductor_ must store the <i class="fab fa-r-project
1414
The bulk of the package code should _not_ be implemented directly within the `shinyApp()` function call.
1515
Instead, internal package functions should be developed to produce and return individual components of the UI and server sides of the Shiny app.
1616

17+
Shiny apps can also be written using [shiny modules][shiny-modules] to allow for
18+
better code organisation and re-usability.
19+
1720
We recommend the following file naming scheme for source files:
1821

1922
- Place internal functions that create observers -- e.g., `shiny::observeEvent()` -- in files named `observers_*.R`.
@@ -48,11 +51,36 @@ shiny::runApp(app, ...)
4851

4952
## Building the package
5053

51-
_Coming soon: comments on build issues for packages that contain Shiny apps._
54+
Packages with `shiny` apps should be built using the standard `R CMD build`
55+
command. The package structure should follow a standard R package structure,
56+
with the Shiny app code stored under the `R/` directory.:
57+
58+
```
59+
MyShinyPackage/
60+
|-- app.R
61+
|-- DESCRIPTION
62+
|-- NAMESPACE
63+
|-- R/
64+
| |-- interface_*.R
65+
| |-- observers_*.R
66+
| |-- outputs_*.R
67+
| |- server_*.R
68+
| └- utils.R
69+
|-- tests/
70+
|-- vignettes/
71+
|-- man/
72+
|-- inst/
73+
[...]
74+
```
75+
76+
An optional `app.R` file can be added to the base directory of the package to
77+
launch the Shiny app using the `shiny::runApp()` or a main shiny app deployment
78+
function.
5279

5380
## Testing
5481

55-
All functions in the package should be testable using standard unit testing tools (e.g., `r BiocStyle::CRANpkg("testthat")`).
82+
All plain non-reactive functions in the package should be testable using
83+
standard unit testing tools (e.g., `r BiocStyle::CRANpkg("testthat")`).
5684

5785
The use of `# nocov start` and `# nocov end` is allowed to ignore part of the code that cannot be tested using traditional unit tests (e.g., `observeEvent`).
5886

@@ -68,6 +96,9 @@ observeEvent(input$example_input, {
6896

6997
Use files `setup-*.R` in the subdirectory `tests/testthat/` to generate only once objects that are used repeatedly as input for the unit tests.
7098

99+
It is recommended to use the `r BiocStyle::CRANpkg("shinytest2")` package to
100+
test visual and computational aspects of Shiny apps.
101+
71102
## Documentation
72103

73104
Man pages documenting functions that return Shiny apps should use the `interactive()` function to demonstrate usage of the app.
@@ -84,22 +115,55 @@ if (interactive()) {
84115
}
85116
```
86117

87-
Although optional, we highly recommend documenting internal functions of packages that contain Shiny apps.
88-
We recommend doing so in a way that is visible to developers but not users:
118+
Although optional, we highly recommend documenting internal functions of
119+
packages that contain Shiny apps. We recommend doing so in a way that is visible
120+
to developers but not users:
89121

90-
- Create man pages named `man/INTERNAL_*.Rd`
91-
+ If using `r BiocStyle::CRANpkg("roxygen2")`, use the tag-value `@rdname INTERNAL_name_of_function`.
92-
- In the file `man/.gitignore` (create it if it does not exist), add the line `INTERNAL_*`
122+
- If using `r BiocStyle::CRANpkg("roxygen2")`, use the tag `@keywords internal`
123+
in the Roxygen block. This will keep the documentation in the package but
124+
remove it from the help page index. You may want to increase the visibility of
125+
internal documentation by linking to it in other help pages within the package
126+
(e.g., within a "for developers" section).
93127

94-
For instance:
128+
For example:
95129

96130
```{r, eval=FALSE}
97-
#' @rdname INTERNAL_build_app
131+
#' @keywords internal
132+
.build_app <- function(...) {
133+
...
134+
}
135+
```
136+
137+
- Alternatively (though less common), prefix the manual pages with `INTERNAL_*`
138+
and add them to `man/.gitignore`.
139+
140+
To set the name of an Rd document, use the `@name` tag in the Roxygen block:
141+
142+
```{r, eval=FALSE}
143+
#' @name INTERNAL_build_app
98144
.build_app <- function(...) {
99145
...
100146
}
101147
```
102148

103149
## Review
104150

105-
_Coming soon: comments on reviewing packages that contain Shiny apps (e.g., points raised during the review process)._
151+
When reviewing a shiny app package, the reviewer should check that the package
152+
follows the guidelines outlined in this document.
153+
154+
We highly recommend that reviewers use the `r BiocStyle::CRANpkg("shinytest2")`
155+
package to test the visual and computational aspects of the Shiny app in
156+
addition to standard unit tests for plain functions.
157+
158+
Reviewers should also check that the package documentation is complete and
159+
accurate, and that the package passes `r BiocStyle::CRANpkg("BiocCheck")` in
160+
addition to `R CMD build` and `check`.
161+
162+
The user experience is very important. Reviewers should ensure that the app is
163+
responsive and that the user interface is intuitive and easy-to-use. The app
164+
should not crash or hang when the user interacts with it.
165+
166+
Errors and warnings should be handled gracefully and should be visible and
167+
intelligible to the user. We recommend using
168+
`r BiocStyle::CRANpkg("shinytoastr")` to display error, warning, and info
169+
messages to the user.

0 commit comments

Comments
 (0)