Skip to content

Viewing the structure of the report document for a module #1522

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

Closed
donyunardi opened this issue May 2, 2025 · 2 comments
Closed

Viewing the structure of the report document for a module #1522

donyunardi opened this issue May 2, 2025 · 2 comments
Labels

Comments

@donyunardi
Copy link
Contributor

donyunardi commented May 2, 2025

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?
image

Originally posted by @donyunardi in insightsengineering/teal.modules.general#862 (comment)

@m7pr
Copy link
Contributor

m7pr commented May 6, 2025

@donyunardi so what's the status of this card?

@donyunardi
Copy link
Contributor Author

As discussed, we will close this issue in favor of insightsengineering/teal.modules.general#875

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

No branches or pull requests

2 participants