-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add vignettes on decorators #843
base: main
Are you sure you want to change the base?
Conversation
Code Coverage Summary
Diff against main
Results for commit: 4ba31eb Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Unit Tests Summary 1 files 22 suites 13m 2s ⏱️ Results for commit e6006d0. ♻️ This comment has been updated with latest results. |
Unit Test Performance Difference
Additional test case details
Results for commit 9fabff5 ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I provided some comments and suggestions on the vignette. It is very easy to follow.
One technical note is to split long lines by each sentence instead of in the middle of one. This makes it nicer diff if only one sentences is modified and also shows which sentences are more complex.
## Introduction | ||
|
||
The outputs produced by `teal` modules, like graphs or tables, are created by the module developer and look a certain way. | ||
It is impossible to design an output that will satisfy every possible user, so the form of the output should be considered a default value that can be customized. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small rewording to link the problem with who benefits from the proposed solution (transformators/decorators).
It is impossible to design an output that will satisfy every possible user, so the form of the output should be considered a default value that can be customized. | |
It is impossible to design an output that will satisfy every possible user. | |
However, we can provide a way to customize the output to app developers. | |
This way the default value can be tailored to the developer and user wishes. |
The decoration process is build upon transformation procedures, introduced in `teal`. While transformators are meant to edit module's input, decorators are meant to adjust the module's output. To distinguish the difference, modules in | ||
`teal.modules.general` have 2 separate parameters: `transformators` and `decorators`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The decoration process is build upon transformation procedures, introduced in `teal`. While transformators are meant to edit module's input, decorators are meant to adjust the module's output. To distinguish the difference, modules in | |
`teal.modules.general` have 2 separate parameters: `transformators` and `decorators`. | |
The decoration process is build upon transformation procedures, introduced in `teal` 0.16. | |
This method can be applied to edit module's input and output. | |
`teal.modules.general` module's have 2 separate parameters: `transformators` and `decorators`, the former for input the later for output. |
|
||
To get a fuller understanding, read more about : | ||
- changing the input data | ||
[in this vignette](https://insightsengineering.github.io/teal/main/articles/data-transform-as-shiny-modulehtml), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[in this vignette](https://insightsengineering.github.io/teal/main/articles/data-transform-as-shiny-modulehtml), | |
[in this vignette](https://insightsengineering.github.io/teal/main/articles/data-transform-as-shiny-module.html), |
Using decorators requires the following: | ||
|
||
1. **Matching Object Names**:<br> | ||
Decorators will reference variables that exist in the `teal` module server function and therefore must use the appropriate variable names. The relevant object names available in each module are included in modules' documentations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decorators will reference variables that exist in the
teal
module server function and therefore must use the appropriate variable names.
Thinking on app developers, perhaps a small clarification would help: this sentence is meant to be the qenv/teal_data class instead of directly the shiny module environment with the reactive variables and so on. It might help when the reader later see within(dat(), ....)
inside the decorators.
Decorators will reference variables that exist in the `teal` module server function and therefore must use the appropriate variable names. The relevant object names available in each module are included in modules' documentations. | ||
2. **Maintaining Object Classes**:<br> | ||
A decorator must not alter the class of the object that it modifies. | ||
This is because a different class may require a different rendering function and that is part of the module structure, which beyond the control of decorators. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because a different class may require a different rendering function and that is part of the module structure, which beyond the control of decorators. | |
This is because a different class may require a different rendering function and that is part of the module structure, which is beyond the control of decorators. |
|
||
### Server | ||
|
||
Here we create a simple decorator that does not provide user input. We will use `tm_g_bivariate` module, to illustrate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we create a simple decorator that does not provide user input. We will use `tm_g_bivariate` module, to illustrate | |
Here we create a simple decorator that does not require user input. We will use `tm_g_bivariate` module, to illustrate |
Note how the input values are passed to the `within()` function using its `...` argument. | ||
See `?teal.code::within.qenv` for more examples. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first line throw me off a bit, perhaps these two lines can be after the code block.
``` | ||
|
||
Note that when the function is used, `output_name` will be passed a character string but the expression passed to `within` needs a `name`/`symbol`, a language object, hence the argument value must be converted to a `name`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a line saying wee will se now how to use them would be helpful. It will introduce the next section and on this more complex/flexible decorator it is more relevant.
Part of insightsengineering/teal#1475
Adds some explanation about decorators functionality of
tmg
, since we will remove/reduce confusing decorators vignette inteal
. Heavily based onCustomizing Module Output
vignette currently existing inteal
, with adjustments to showteal.modules.general
modules.https://github.com/insightsengineering/teal/blob/c70299587cdf8280c75f7320ae09cd3c67c79837/vignettes/customizing-module-output.Rmd