insightsengineering / insightsengineering/teal
Improve print for teal_data_module/teal_transform_module to be more useful
- Dominant language
- R
- Stars
- 263
- Forks
- 59
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 5
Description
Currently, the `teal_data_module` and `teal_transform_module` just prints the UI and Server functions and the attributes when we print them. It will be nice if we can format this to showcase key information.
Similar to #1378. Additionally, it will be helpful if we can use this format to further show more information in the print method of the `teal_module` that uses transformations.
Example object and current print:
```r
tdm <- teal_data_module(
ui = function(id) {
ns <- NS(id)
actionButton(ns("submit"), label = "Load data")
},
server = function(id) {
moduleServer(id, function(input, output, session) {
eventReactive(input$submit, {
data <- within(
teal_data(),
{
dataset1 <- iris
dataset2 <- mtcars
}
)
datanames(data) <- c("dataset1", "dataset2")
data
})
})
}
)
```
```
> tdm
$ui
function(id) {
ns <- NS(id)
actionButton(ns("submit"), label = "Load data")
}
$server
function(id) {
data_out <- server(id)
decorate_err_msg(
assert_reactive(data_out),
pre = sprintf("From: 'teal_data_module()':\nA 'teal_data_module' with \"%s\" label:", label),
post = "Please make sure that this module returns a 'reactive` object containing 'teal_data' class of object." # nolint: line_length_linter.
)
}
attr(,"label")
[1] "data module"
attr(,"class")
[1] "teal_data_module"
attr(,"once")
[1] TRUE
```
Contributor guide
Assessment
This issue has not been assessed yet.