Skip to content

Commit

Permalink
remove examples and link to the vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
m7pr committed Nov 19, 2024
1 parent d52361b commit a3d3de8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 59 deletions.
42 changes: 5 additions & 37 deletions R/tm_a_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,50 +42,20 @@
#'
#' @inherit shared_params return
#'
#' @section Decorating Module Outputs:
#'
#' Decorating module outputs involves modifying the tables and plots generated by a module. This module provides the
#' ability to execute custom R code to adjust the visual or structural properties of objects displayed within the
#' application.
#'
#' The code specified in [`teal_transform_module`] is executed prior to rendering the outputs in the application. This
#' allows developers to modify attributes such as titles, labels, sizes, limits, and other features of rendered tables
#' and plots. However, decorators should be applied with careful consideration of the module's internal object names
#' to ensure compatibility.
#'
#' To customize an output, developers need to identify the name of the table or plot to be modified within the
#' `teal_transform_module`. This requires specifying a `server` function that modifies the targeted object in the
#' `data` object (of class `teal_data`). Since each module may use different internal object names or types for its
#' outputs, there is no universal code to achieve this. However, `teal` provides convenient wrappers to simplify the
#' process of decorating module outputs:
#' @section Decorating `tm_a_regression`:
#'
#' - **Decorator as a Language/Expression**: Specify a simple R expression to modify the object of interest.
#' For example,`plot <- plot + ggtitle("Custom Title")`. The expression must be valid and compatible with the module's
#' internal environment.
#' - **Decorator as a Function**: Provide a function that accepts the output object and modifies it as desired.
#' When using this approach, the function does not need to align with the module’s internal naming conventions for its
#' objects.
#' This module creates below objects that can be modified with decorators:
#' - `plot` (`ggplot2`)
#'
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation.
#'
#' @section Decorating `tm_a_regression`:
#'
#' This module creates below objects that can be modified with decorators:
#' - `plot` (`ggplot2`)#'
#'
#' @examplesShinylive
#' library(teal.modules.general)
#' interactive <- function() TRUE
#' {{ next_example }}
#' @examples
#'
#' footnote_regression <- teal_transform_module(
#' server = make_teal_transform_server(expression(
#' plot <- plot + labs(caption = deparse(summary(fit)[[1]]))
#' ))
#' )
#'
#' # general data example
#' data <- teal_data()
#' data <- within(data, {
Expand Down Expand Up @@ -117,8 +87,7 @@
#' multiple = TRUE,
#' fixed = FALSE
#' )
#' ),
#' decorators = list(footnote_regression)
#' )
#' )
#' )
#' )
Expand Down Expand Up @@ -163,8 +132,7 @@
#' multiple = TRUE,
#' fixed = FALSE
#' )
#' ),
#' decorators = list(footnote_regression)
#' )
#' )
#' )
#' )
Expand Down
26 changes: 5 additions & 21 deletions R/tm_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,21 @@
#'
#' @inherit shared_params return
#'
#' @inheritSection tm_a_regression Decorating Module Outputs
#' @section Decorating `tm_outliers`:
#'
#' This module creates below objects that can be modified with decorators:
#' - `table` (`data.frame`)
#' - `plot` (`ggplot2`)
#'
#' For additional details and examples of decorators, refer to the vignette
#' `vignette("decorate-modules-output", package = "teal")` or the [`teal_transform_module()`] documentation.
#'
#' @examplesShinylive
#' library(teal.modules.general)
#' interactive <- function() TRUE
#' {{ next_example }}
#' @examples
#'
#' module_decorator <- teal_transform_module(
#' server = make_teal_transform_server(
#' expression({
#' plot <- plot + ggplot2::ggtitle("A new title")
#' })
#' )
#' )
#'
#' # general data example
#' data <- teal_data()
#' data <- within(data, {
Expand Down Expand Up @@ -84,8 +78,7 @@
#' multiple = TRUE
#' )
#' )
#' ),
#' boxplot_decorator = module_decorator
#' )
#' )
#' )
#' )
Expand All @@ -99,14 +92,6 @@
#' {{ next_example }}
#' @examples
#'
#' module_decorator <- teal_transform_module(
#' server = make_teal_transform_server(
#' expression({
#' plot <- plot + ggplot2::ggtitle("A new title")
#' })
#' )
#' )
#'
#' # CDISC data example
#' data <- teal_data()
#' data <- within(data, {
Expand Down Expand Up @@ -145,8 +130,7 @@
#' multiple = TRUE
#' )
#' )
#' ),
#' boxplot_decorator = module_decorator
#' )
#' )
#' )
#' )
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' with text placed before the output to put the output into context. For example a title.
#' @param post_output (`shiny.tag`) optional, text or UI element to be displayed after the module's output,
#' adding context or further instructions. Elements like `shiny::helpText()` are useful.
#' @param decorators (`list` of `teal_transform_module`) optional,
#' @param decorators `r lifecycle::badge("experimental")` (`list` of `teal_transform_module`) optional,
#' decorator for tables or plots included in the module.
#'
#' @param alpha (`integer(1)` or `integer(3)`) optional, specifies point opacity.
Expand Down

0 comments on commit a3d3de8

Please sign in to comment.