| Title: | Analyze the File Contents of 'shiny' Directories |
|---|---|
| Description: | Provides tools for analyzing and understanding the file contents of large 'shiny' application directories. The package extracts key information about render functions, reactive functions, and their inputs from app files, organizing them into structured data frames for easy reference. This streamlines the onboarding process for new contributors and helps identify areas for optimization in complex 'shiny' codebases with multiple files and sourcing chains. |
| Authors: | Jasmine Daly [aut, cre] (ORCID: <https://orcid.org/0000-0001-8006-2428>) |
| Maintainer: | Jasmine Daly <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.1 |
| Built: | 2026-06-08 08:29:35 UTC |
| Source: | https://github.com/dalyanalytics/shinyfa |
This function processes a Shiny server script, identifying render functions, their reactivity types, and any input dependencies.
analyze_shiny_reactivity(file_path)analyze_shiny_reactivity(file_path)
file_path |
A string representing the path to the R file. |
A data frame summarizing the reactivity structure of the file.
Determines whether a given block of Shiny code contains reactive elements such as
reactive(), eventReactive(), observeEvent(), etc.
classify_reactivity(render_block)classify_reactivity(render_block)
render_block |
A character vector representing a block of Shiny server code. |
A string indicating the type of reactivity detected.
Identifies all input$ dependencies within a render block, including cases like input$var and input[['var']].
extract_input_dependencies(render_block)extract_input_dependencies(render_block)
render_block |
A character vector representing a block of Shiny server code. |
A string of unique input IDs used within the render block, or "None" if no inputs are found.
Identifies reactive() assignments that are stored in variables and returns a data frame.
Additionally, it checks for any input dependencies inside the reactive() function.
extract_named_reactives(server_code)extract_named_reactives(server_code)
server_code |
A character vector representing lines of Shiny server code. |
A data frame containing named reactive expressions with their corresponding input dependencies.
Identifies output$ assignments in a Shiny server file and extracts
their associated render function types.
extract_output_assignments(server_code)extract_output_assignments(server_code)
server_code |
A character vector representing lines of Shiny server code. |
A list of lists, where each list contains an index, output ID, and render function type.
This function identifies all Shiny input functions (e.g., selectInput, textInput, numericInput) and output functions (e.g., plotOutput, tableOutput, or custom output functions) in a UI script, and extracts the corresponding ids. It skips over lines that are source() calls.
extract_ui_features(ui_code)extract_ui_features(ui_code)
ui_code |
A character vector representing lines of Shiny UI code. |
A data frame containing the input/output functions and their associated ids.
This function reads a Shiny server file and checks whether it only contains
source() calls or is empty. If so, it returns NULL to indicate the file should be skipped.
read_shiny_file(file_path)read_shiny_file(file_path)
file_path |
A string representing the path to the R file. |
A character vector containing the file's lines if valid, otherwise NULL.