Expand description
graphs-tui - Terminal renderer for Mermaid and D2 diagrams
§Mermaid Flowchart Example
use graphs_tui::{render_mermaid_to_tui, RenderOptions};
let input = "flowchart LR\nA[Start] --> B[End]";
let result = render_mermaid_to_tui(input, RenderOptions::default()).unwrap();
println!("{}", result.output);
for warning in &result.warnings {
eprintln!("Warning: {warning}");
}§State Diagram Example
use graphs_tui::{render_state_diagram, RenderOptions};
let input = "stateDiagram-v2\n [*] --> Idle\n Idle --> Running";
let result = render_state_diagram(input, RenderOptions::default()).unwrap();
println!("{}", result.output);§Pie Chart Example
use graphs_tui::{render_pie_chart, RenderOptions};
let input = "pie\n \"Chrome\" : 65\n \"Firefox\" : 35";
let result = render_pie_chart(input, RenderOptions::default()).unwrap();
println!("{}", result.output);§D2 Example
use graphs_tui::{render_d2_to_tui, RenderOptions};
let input = "A -> B: connection";
let result = render_d2_to_tui(input, RenderOptions::default()).unwrap();
println!("{}", result.output);§Sequence Diagram Example
use graphs_tui::{render_sequence_diagram, RenderOptions};
let input = "sequenceDiagram\n Alice->>Bob: Hello\n Bob-->>Alice: Hi!";
let result = render_sequence_diagram(input, RenderOptions::default()).unwrap();
println!("{}", result.output);§Auto-detect Format
use graphs_tui::{render_diagram, RenderOptions};
let mermaid_input = "flowchart LR\nA --> B";
let d2_input = "A -> B";
// Automatically detects format
let _ = render_diagram(mermaid_input, RenderOptions::default());
let _ = render_diagram(d2_input, RenderOptions::default());Structs§
- Edge
- An edge connecting two nodes
- Graph
- The complete graph structure
- Node
- A node in the flowchart
- Render
Options - Options for rendering the diagram
- Render
Result - Result of rendering a diagram
- Subgraph
- A subgraph/group of nodes
- Table
Field - A field inside a sql_table or class node (D2)
Enums§
- Diagram
Format - Diagram format
- Diagram
Warning - Structured warning emitted during layout or rendering
- Direction
- Flow direction for the diagram
- Edge
Style - Style of an edge/link
- Mermaid
Error - Errors that can occur during mermaid parsing/rendering
- Node
Shape - Shape of a node
Constants§
- SUPPORTED_
LANGUAGES - Languages supported by graphs-tui.
Functions§
- check
- Validate diagram without rendering output.
- compute_
layout - Compute layout for all nodes in the graph
- compute_
layout_ with_ options - Compute layout for all nodes with render options (considers max_width)
- detect_
format - Detect the diagram format from input
- is_
supported - Check if a language string is supported for rendering.
- render
- Unified entry point — render a diagram by language name.
- render_
d2_ to_ tui - Render D2 diagram syntax to terminal-displayable text
- render_
diagram - Render diagram with auto-detection of format
- render_
mermaid_ to_ tui - Render mermaid flowchart syntax to terminal-displayable text
- render_
pie_ chart - Render mermaid pie chart to terminal-displayable text
- render_
sequence_ diagram - Render mermaid sequence diagram to terminal-displayable text
- render_
state_ diagram - Render mermaid state diagram to terminal-displayable text
Type Aliases§
- NodeId
- Node identifier type