Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1187 decorate output@main #1357

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft

1187 decorate output@main #1357

wants to merge 14 commits into from

Conversation

gogonzo
Copy link
Contributor

@gogonzo gogonzo commented Sep 30, 2024

WIP
@kpagacz

@gogonzo gogonzo marked this pull request as draft September 30, 2024 08:22
@@ -315,7 +313,12 @@ modules <- function(..., label = "root") {

#' @rdname teal_modules
#' @export
format.teal_module <- function(x, indent = 0, ...) {
format.teal_module <- function(x, ...) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed indent from the module() documentation. It is completely unnecessary to display indent in the public docs.

@@ -262,7 +256,7 @@ srv_teal_module.teal_module <- function(id,
)

is_transformer_failed <- reactiveValues()
transformed_teal_data <- srv_transform_data(
transformed_teal_data <- srv_teal_transform_module(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this name is more accurate and more straighforward.
teal_transform_module is consumed by ui_teal_transform_module and srv_teal_transform_module

R/modules.R Outdated
@@ -48,14 +48,12 @@ setOldClass("teal_modules")
#' @param server_args (named `list`) with additional arguments passed on to the server function.
#' @param ui_args (named `list`) with additional arguments passed on to the UI function.
#' @param x (`teal_module` or `teal_modules`) Object to format/print.
#' @param indent (`integer(1)`) Indention level; each nested element is indented one level more.
#' @param transformers (`list` of `teal_data_module`) that will be applied to transform the data.
#' @param transformers (`list` of `teal_transform_module`) that will be applied to transform module's data input.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to rather link transformers with decorators and don't refer teal_transform_module to teal_data_module.

#' Some [`teal_modules`] enables app developer to inject custom shiny module to modify displayed output.
#' To handle these `decorators` inside of your module use [ui_teal_transform_module()] and [srv_teal_transform_module].
#' (todo: write more about how to handle decorators: they need to go through ui_args/srv_args and then be consumed by
#' ui/srv_teal_transform_module()... . Alternatively, decorators could be a [module()]'s argument)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A reference to the vignette would be nice here :)

#' @description
#' `r lifecycle::badge("experimental")`
#'
#' `teal_transform_module` creates a shiny-module to transform data in a `teal` application.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not entirely true, now it also supports output decoration!

#' # Decorating `teal` module's output
#'
#' `teal_transform_module`'s purpose is to modify any object created in [`teal.data::teal_data`]. It means that an
#' app-developer can use `teal_transform_module` to modify data but also outputted tables, listings and graphs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' app-developer can use `teal_transform_module` to modify data but also outputted tables, listings and graphs.
#' app-developer can use `teal_transform_module` to modify not only data but also tables, listings and graphs.

#' `teal_transform_module`'s purpose is to modify any object created in [`teal.data::teal_data`]. It means that an
#' app-developer can use `teal_transform_module` to modify data but also outputted tables, listings and graphs.
#' Some [`teal_modules`] enables app developer to inject custom shiny module to modify displayed output.
#' To handle these `decorators` inside of your module use [ui_teal_transform_module()] and [srv_teal_transform_module].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' To handle these `decorators` inside of your module use [ui_teal_transform_module()] and [srv_teal_transform_module].
#' To handle these `decorators` inside of your module, use [ui_teal_transform_module()] and [srv_teal_transform_module].

#' ```
#'
#' Above can be simplified to presented below, where `level` will be automatically substituted with
#' respective input matched by its name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' respective input matched by its name.
#' the respective input matched by its name.

#' # `server` as a language
#'
#' Server function in `teal_transform_module` must return `reactive` containing [teal.data::teal_data] object.
#' Consider sinmple transformer which doesn't require any advanced reactivity, example `server` might have a
Copy link
Contributor

@kpagacz kpagacz Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' Consider sinmple transformer which doesn't require any advanced reactivity, example `server` might have a
#' Consider a simple transformer, which doesn't require any advanced reactivity, example `server` might have a

#' `shiny` module server function; that takes `id` and `data` argument,
#' where the `id` is the module id and `data` is the reactive `teal_data` input.
#' The server function must return reactive expression containing `teal_data` object.
#' To simplify use [make_teal_transform_server()].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' To simplify use [make_teal_transform_server()].
#' To simplify, use [make_teal_transform_server()].

#'
#' A factory function to simplify creation of a [`teal_transform_module`]'s server. Specified `expr`
#' is wrapped in a shiny module function and output can be passed to the `server` argument in
#' [teal_transform_module()] call. Such server function can be linked with ui and values from the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' [teal_transform_module()] call. Such server function can be linked with ui and values from the
#' [teal_transform_module()] call. Such a server function can be linked with ui and values from the

#' app-developer can use `teal_transform_module` to modify data but also outputted tables, listings and graphs.
#' Some [`teal_modules`] enables app developer to inject custom shiny module to modify displayed output.
#' To handle these `decorators` inside of your module use [ui_teal_transform_module()] and [srv_teal_transform_module].
#' (todo: write more about how to handle decorators: they need to go through ui_args/srv_args and then be consumed by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can write or you can just link to the vignette which contains an example of the proper handling. It's actually better to link than to write. Just add one sentence about - as a module developer, you can see to learn how to properly handle the decorators inside your module.

#'
#' `teal_transform_module` creates a shiny-module to transform data in a `teal` application.
#'
#' # Transforming `teal` module's input
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to mention the advantages of using the transform modules for these tasks. They come with error handling out of the box, etc. It's their biggest selling point and it's what stands them apart from just embedding app dev-supplied shiny modules into a module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants