-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from Appsilon/develop
Release v0.8.0
- Loading branch information
Showing
33 changed files
with
1,677 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: rhino | ||
Title: A Framework for Enterprise Shiny Applications | ||
Version: 0.7.0 | ||
Version: 0.8.0 | ||
Authors@R: | ||
c( | ||
person("Kamil", "Zyla", role = c("aut", "cre"), email = "[email protected]"), | ||
|
@@ -17,6 +17,8 @@ Encoding: UTF-8 | |
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.1.2 | ||
VignetteBuilder: knitr | ||
Depends: | ||
R (>= 2.10) | ||
Imports: | ||
box, | ||
cli, | ||
|
@@ -37,5 +39,6 @@ Imports: | |
Suggests: | ||
knitr, | ||
rmarkdown | ||
LazyData: true | ||
Config/testthat/edition: 3 | ||
Config/testthat/parallel: true |
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,12 @@ | ||
#' Population of rhinos | ||
#' | ||
#' A dataset containing population of 5 species of rhinos | ||
#' | ||
#' @format A data frame with 58 rows and 3 variables: | ||
#' \describe{ | ||
#' \item{Year}{year} | ||
#' \item{Population}{rhinos population} | ||
#' \item{Species}{rhinos species} | ||
#' } | ||
#' @source \url{https://ourworldindata.org/} | ||
"rhinos" |
Binary file not shown.
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# File generated by Rhino. Do not edit. | ||
# Rhino / shinyApp entrypoint. Do not edit. | ||
rhino::app() |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Logic: application code independent from Shiny. | ||
# https://appsilon.github.io/rhino/articles/rhino-project-structure.html | ||
# https://appsilon.github.io/rhino/articles/explanation-project-structure.html |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# View: Shiny modules and related code. | ||
# https://appsilon.github.io/rhino/articles/rhino-project-structure.html | ||
# https://appsilon.github.io/rhino/articles/explanation-project-structure.html |
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.
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
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,102 @@ | ||
--- | ||
title: "Explanation: Box modules" | ||
output: rmarkdown::html_vignette | ||
vignette: > | ||
%\VignetteIndexEntry{Explanation: Box modules} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\VignetteEncoding{UTF-8} | ||
--- | ||
|
||
# Rationale | ||
With large applications it is critical for maintainability | ||
to properly structure your code using files and directories. | ||
R comes with the `library()` and `source()` functions, | ||
but its functionality is limited when it comes | ||
to dividing your code into modules and expressing their dependencies. | ||
|
||
To address this, Rhino uses the [box](https://klmr.me/box/) R package, | ||
which allows you to modularize your code in a similar way to languages like Python and Java: | ||
```r | ||
box::use( | ||
dplyr, # Import dplyr. Its functions can be used via `$`, e.g. `dplyr$filter`. | ||
shiny[reactive], # Import the `reactive()` function from shiny package. | ||
) | ||
box::use( | ||
logic/data_validation, # Import the `logic/data_validation.R` module. | ||
) | ||
``` | ||
|
||
Box modules force you to be explicit about the dependencies between your files and packages. | ||
The graph of dependencies is visible at a glance in an app developed with box, | ||
while the traditional approach (`global.R`, `library()`, `source()`) | ||
makes it easy to build an app which only the author understands. | ||
Introduction of box to existing apps written without it | ||
has helped to improve the code structure and find bugs. | ||
|
||
# Features | ||
The best place to learn about box is its official [documentation](https://klmr.me/box/). | ||
Some useful box features are also explained in the sections below. | ||
|
||
## Init files | ||
Objects exported by an `__init__.R` file can be imported from its parent directory. | ||
|
||
### Example | ||
Assume we have an `app/foo/__init__.R` file with the following content: | ||
```r | ||
#' @export | ||
bar <- "Hello!" | ||
``` | ||
|
||
We can now import `bar` as if it was defined in `app/foo.R`: | ||
```r | ||
box::use( | ||
app/foo[bar] | ||
) | ||
``` | ||
|
||
This mechanism can be used in combination with reexports | ||
to make it easier to import multiple modules from a single directory. | ||
|
||
## Reexports | ||
A module can reexport objects imported from a different module | ||
by applying `#' @export` to a `box::use()` statement. | ||
|
||
### Example | ||
Assume we have modules `analysis_tab.R` and `download_tab.R` in the `app/view` directory. | ||
We can reexport them from `app/view/__init__.R` like this: | ||
```r | ||
#' @export | ||
box::use( | ||
app/view/analysis_tab, | ||
app/view/download_tab | ||
) | ||
``` | ||
|
||
The following `box::use()` statements are now equivalent: | ||
```r | ||
box::use( | ||
app/view/analysis_tab, | ||
app/view/download_tab, | ||
) | ||
box::use( | ||
app/view[analysis_tab, download_tab], | ||
) | ||
``` | ||
|
||
# Known issues | ||
|
||
### Lazy-loaded data | ||
Box 1.1.0 doesn't support lazy-loaded [data](https://r-pkgs.org/data.html#data-data), | ||
so e.g. `box::use(datasets[mtcars])` won't work. | ||
This feature should be available in the next release | ||
(see this [issue](https://github.com/klmr/box/issues/219)). | ||
For now please use `datasets::mtcars` in your code. | ||
|
||
### Trailing commas | ||
Box 1.1.0 allows trailing commas in `box::use()` statements and code, | ||
but they can cause problems in some circumstances: | ||
|
||
1. Reexports ([issue](https://github.com/klmr/box/issues/263)). | ||
2. Functions accessed via `$` ([issue](https://github.com/klmr/box/issues/266)). | ||
|
||
Both issues should be fixed in the nearest release. |
43 changes: 43 additions & 0 deletions
43
vignettes/explanation-node-js-javascript-and-sass-tools.Rmd
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,43 @@ | ||
--- | ||
title: "Explanation: Node.js - JavaScript and Sass tools" | ||
output: rmarkdown::html_vignette | ||
vignette: > | ||
%\VignetteIndexEntry{Explanation: Node.js - JavaScript and Sass tools} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\VignetteEncoding{UTF-8} | ||
--- | ||
|
||
[Node.js](https://nodejs.org/en/about/) is a runtime environment | ||
which can execute JavaScript code outside a web browser. | ||
It is used widely for web development. | ||
Its package manager, [npm](https://docs.npmjs.com/about-npm), | ||
makes it easy to install virtually any JavaScript library. | ||
|
||
Rhino uses Node.js to provide state of the art tools | ||
for working with JavaScript and Sass. | ||
In the future it might also become an easy way to add any JS library to your Shiny app. | ||
|
||
The following functions require Node.js to work: | ||
|
||
1. `build_js()` | ||
2. `build_sass()` (with `sass: node` configuration in `rhino.yml`) | ||
3. `lint_js()` | ||
4. `lint_sass()` | ||
5. `test_e2e()` | ||
|
||
You don't need to worry about Node.js most of the time. | ||
You need to install it on your system along with [yarn](https://classic.yarnpkg.com/lang/en/) | ||
(an alternative package manager for Node.js). | ||
The rest will be handled automatically. | ||
|
||
Under the hood Rhino will create a `.rhino/node` directory in your project | ||
to store the specific libraries needed by these tools. | ||
This directory is git-ignored by default and safe to remove. | ||
|
||
The `build_sass()` function is worth an additional comment. | ||
Depending on the configuration in `rhino.yml` | ||
it can use either the [sass](https://www.npmjs.com/package/sass) Node.js package | ||
or the [sass](https://rstudio.github.io/sass/) R package. | ||
We recommend the Node.js version, as it is the primary, actively developed implementation of Sass. | ||
In contrast, the R package uses the deprecated | ||
[LibSass](https://sass-lang.com/blog/libsass-is-deprecated) implementation. |
Oops, something went wrong.