strboul / supreme

Generate UML diagrams of Shiny modules
Other
60 stars 5 forks source link

supreme

Travis build
status AppVeyor build
status CRAN status
badge CRAN mirror
downloads Coverage
status

As a ‘Shiny application’, developed with ‘Shiny modules’, gets bigger, it becomes more difficult to track the relationships and to have a clear overview of the module hierarchy. supreme is a tool to help developers visualize the structure of their ‘Shiny applications’ developed with modules.

Therefore, you are able to:

  1. Visualize relationship of modules in existing applications

  2. Design new applications from scratch


:warning: supreme isn't yet compatible with the new moduleServer syntax introduced in the Shiny version 1.5.0 :warning:

Usage

0. The model language

A graph consists of five main fields:

  1. Module name (always required)

  2. Module inputs (except the defaults: input, output, session)

  3. Module outputs

  4. Module returns

  5. Calling modules, which are modules called a the module

1. Model graph for existing applications

library(supreme)
path <- example_app_path()
obj <- supreme(src_file(path))
graph(obj)


2. Model new applications

- name: server
  calling_modules:
    - items_tab_module_server: ItemsTab
    - customers_tab_module_server: CustomersTab
    - transactions_tab_module_server: TransactionsTab
  src: app.R

- name: customers_tab_module_server
  input: customers_list
  output:
    - paid_customers_table
    - free_customers_table
  src: module-customers.R

- name: items_tab_module_server
  input:
    - items_list
    - is_fired
  calling_modules:
    - module_modal_dialog: ~
  src: module-items.R

- name: transactions_tab_module_server
  input:
    - table
    - button_clicked
  output: transactions_table
  return: transactions_keys
  src: module-transactions.R

- name: module_modal_dialog
  input:
    - text
  src: module-utils.R

There are some special rules when creating model objects with YAML:

model_yaml <- src_yaml(text = model)
obj <- supreme(model_yaml)

Known limitations

Installation

You can install the released version from CRAN:

install.packages("supreme")

Or get the development version from GitHub:

# install.packages("devtools")
devtools::install_github("strboul/supreme")

Acknowledgment

License

MIT © Metin Yazici