Skip to content

[FEATURE] Add preswald export --format markdown CLI Command for Generating Markdown Reports #647

@amrutha97

Description

@amrutha97

Enable users to export the current Preswald app's rendered state into a well-formatted Markdown report via the CLI. This makes it easy to generate lightweight, version-controllable, and GitHub/GitLab-friendly snapshots of an app’s output.


Motivation

Markdown exports are useful for:

  • Creating reproducible, readable analysis logs
  • Sharing results via GitHub, Notion, or static documentation sites
  • Archiving outputs alongside source code
  • Enhancing developer workflows with Markdown-based reporting

This feature simplifies app-to-doc workflows without requiring frontend interaction or custom tooling.


Acceptance Criteria

  • Add CLI command:

    preswald export --format markdown --output report.md
  • Run app in headless mode (like preswald run, but silent)

  • Capture the rendered state of all static and interactive components

  • Generate a structured .md file that includes:

    • Markdown headers from text()
    • Data tables from table()
    • Inline callouts from alert()
    • Markdown-renderable forms of progress, checkbox, selectbox, etc.
    • Chart references or alt text from plotly() (optional PNG if --include-images is used)
  • Default output path: exports/app.md if --output is not provided


Implementation Plan

  • Extend preswald/cli.py with export --format markdown
  • Add MarkdownExporter class in preswald/utils/exporter.py
  • Hook into component registry to collect component render calls (reuse internal service from run)
  • Implement serialization logic for each supported component type
  • Optional: Use Plotly's to_image() for embedding static PNGs of charts (if --include-images is enabled)

Testing Plan

Run:

preswald run
preswald export --format markdown --output output/report.md

Validate:

  • report.md is created and readable in VS Code / GitHub preview
  • Markdown syntax is valid and renders cleanly
  • Components show up in correct order, with all user-visible state

Example snapshot:

# My Dashboard

> ✅ Model Training Complete

## Accuracy Chart  
![Accuracy over time](charts/fig1.png)

## Config  
- Region: North America  
- Slider value: 70

## Data Preview  
| Name | Score |  
|------|-------|  
| Alice | 88.4 |  
| Bob   | 92.1 |

Related Files

  • preswald/cli.py
  • preswald/service.py
  • preswald/utils/exporter.py
  • (optional) Add plotly[kaleido] to extras for chart export

Extra

  • --include-code to append the Python source file
  • --include-images to embed static charts
  • --format html for rich HTML export
  • Add GitHub Action for CI-based report generation

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions