Closed
Description
Viewing the structure of the report document for a module
Currently, users have to look at the source code or inspect the server
element to understand the structure of card_fun
in a module, in order to see how the report document is structured for a teal module.
Example:
r$> x <- my_custom_module()
r$> body(x$server)
{
moduleServer(id, function(input, output, session) {
shiny::updateSelectInput(inputId = "datasets", choices = datanames(data()))
observeEvent(input$datasets, {
req(input$datasets)
only_numeric <- sapply(data()[[input$datasets]],
is.numeric)
shiny::updateSelectInput(inputId = "variables", choices = names(data()[[input$datasets]])[only_numeric])
})
result <- reactive({
req(input$datasets)
req(input$variables %in% names(data()[[input$datasets]]))
new_data <- within(data(), {
my_plot <- ggplot(input_dataset, aes(x = input_vars)) +
geom_histogram(binwidth = input_binwidth, fill = "skyblue",
color = "black")
}, input_dataset = as.name(input$datasets), input_vars = as.name(input$variables),
input_binwidth = input$binwidth, label = "plot")
new_data
})
output$plt <- shiny::renderPlot({
result()[["my_plot"]]
})
teal.widgets::verbatim_popup_srv(id = "rcode", verbatim_content = reactive(get_code(result())),
title = "Code to reproduce the analysis")
plot_code_r <- pull_code(result, labels = "plot")
card_fun <- reactive({ ###### <---- This is the part that user will have to look for
teal.reporter::report_document("## Plot", teal.reporter::code_chunk(plot_code_r()),
result()[["my_plot"]])
})
list(report_card = card_fun)
})
}
Is it possible to provide a better way for users to view the current structure of the reporter for a module?
Can we extend our format.teal_module
method to include this information?
Originally posted by @donyunardi in insightsengineering/teal.modules.general#862 (comment)