-
Notifications
You must be signed in to change notification settings - Fork 0
/
_leprechaun_features.qmd
63 lines (63 loc) · 17 KB
/
_leprechaun_features.qmd
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
::: {style="font-size: 0.85em;"}
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| Feature | Arguments/Options | Description/Comments |
+=========================================+================================================================================================+==============================================================================================================================================+
| `scaffold()` | `ui`: can be one of `"navbarPage"` or `"fluidPage"` | The initial 'setup' function that builds the leprechaun files in `R/` and `inst/` |
| | | |
| | `bs_version`: Bootstrap version | |
| | | |
| | `overwrite` : recreate folder structure | |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| `scaffold_leprechaun()` (from `packer`) | `react` : include React? | This function comes from [the `packer` package](https://packer.john-coene.com/#/references/scaffold_leprechaun) for integrating JS with R. |
| | | |
| | `vue` : include Vue? | This creates the following non-standard R package folders and files: |
| | | |
| | `use_cdn` : use the CDN for react or vue dependencies? | - `srcjs/` and `node_modules/` |
| | | - `package-lock.json`, `package.json`, `webpack.common.js,` `webpack.dev.js`, and `webpack.prod.js` files |
| | `edit` : open pertinent files | |
| | | *These non-standard folders are added to the `.Rbuildignore` and `.gitignore`* (but it would be nice to know more about what they do). |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| `use_packer()` | Assumes `scaffold_leprechaun()` from packer has been run | Sets up application to use `packer` utilities for bundling JavaScript. |
| | | |
| | | - Creates `inst/dev/packer.R` |
| | | - Adds `packer` to `Suggests` in `DESCRIPTION` |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| `build()` | Returns `TRUE`/`FALSE` if build was successful. | Used to 'bundle' various resources (i.e., from `packer` and the other `use_` functions) |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| `use_sass()` | | Creates `inst/dev/sass.R` |
| | | |
| | | Adds `sass` to `DESCRIPTION` under `Suggests` |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| `use_html_utils()` | Adds `R/html-utils.R` | Adds `htmltools` to `Imports` field in `DESCRIPTION` |
| | | |
| | | `R/html-utils.R` contains a variety of utility functions using HTML tags (i.e., `span()`, `div()`, etc.) |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| `use_endpoints_utils()` | Adds `R/endpoint-utils.R` | Adds `jsonlite` to `Imports` field in `DESCRIPTION` |
| | | |
| | | `R/endpoint-utils.R` contains utility functions for creating an HTTP response object and the `LEPRECHAUN_SERIALISER` environmental variable. |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| `use_js_utils()` | Adds `srcjs/leprechaun-utils.js` and `R/utils-js.R` | Requires running `leprechaun::build()` to bundle .js |
| | | |
| | Adds import statement to `srcjs/index.js` | |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| `use_config()` | Adds `R/config.R` and `inst/config.yml` | Adds `yml` to `Imports` field in `DESCRIPTION` |
| | | |
| | `inst/config.yml` initially contains `production: true` | `R/config.R` contains functions for reading and getting configuration values. |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| `add_module()` | Using `add_module("name")` : | *It would be nice if the modules had consistent naming (the UI function uses `camelCase()` and the server function is `snake_case()`).* |
| | | |
| | 1. Creates `R/module_name.R` | By default, modules aren't exported (i.e., with `@export`), but are included in the package index (i.e., with `@keywords internal`) |
| | 2. UI function: `nameUI()` | |
| | 3. Server function: `name_server()` | Each module automatically includes: |
| | | |
| | | `send_message <- make_send_message(session)` |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| `add_app_file()` | Adds `app.R` file to root directory. | Handy for quickly launching the app during development (and deployment). |
| | | |
| | Includes call to `pkgload::load_all()` with `reset` set to `TRUE` and `helpers` set to `FALSE` | |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| `.onLoad()` | Used to add external files to app (images, html, etc.) | Combines Shiny's `addResourcePath()` and `system.file()`. |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
| `serveAssets()` | `modules` argument can be used to include JavaScript modules | Adds dependencies for JavaScript, CSS, and HTML. |
+-----------------------------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
:::