[Experimental] This function displays a shiny app's module structure, assuming it is built on top of module functions named a certain way (adjustable through the pattern argument) and calling each other. If you call for instance flow_view_shiny() on a function that runs the app and uses both the main server and ui functions, you'll display the full graph of server and ui modules.

flow_view_shiny(
  fun,
  max_depth = Inf,
  trim = NULL,
  promote = NULL,
  demote = NULL,
  hide = NULL,
  show_imports = c("functions", "packages", "none"),
  out = NULL,
  lines = TRUE,
  pattern = "(_ui)|(_server)|(Ui)|(Server)|(UI)|(SERVER)"
)

Arguments

fun

The function that runs the app

max_depth

An integer, the maximum depth to display

trim

A vector or list of function names where the recursion will stop

promote

A vector or list of external functions to show as internal functions

demote

A vector or list of internal functions to show as external functions

hide

A vector or list of internal functions to completely remove from the chart

show_imports

Whether to show imported "functions", only "packages", or "none"

out

a path to save the diagram to. Special values "html", "htm", "png", "pdf", "jpg" and "jpeg" can be used to export the object to a temp file of the relevant format and open it, if a regular path is used the format will be guessed from the extension.

lines

Whether to show the number of lines of code next to the function name

pattern

A regular expression used to detect ui and server functions

Value

A flow diagram object.

Details

It is wrapper around flow_view_deps() which demotes every object that is not a server function, a ui function or a function calling either. What is or isn't considered as a server or ui function depends on a regular expression provided through the pattern argument. For a more general way of displaying all dependencies (not focused on modules), use flow_view_deps().

Examples

if (requireNamespace("esquisse", quietly = TRUE)) {
  flow_view_shiny(esquisse::esquisser, show_imports = "none")
}