Mermaid Builder
Mermaid Builder is a Rust crate that provides a type-safe, builder-pattern-based API for generating Mermaid diagram syntax. It allows you to define diagrams programmatically in Rust and export them as strings that can be rendered by Mermaid tools.
The crate is no_std compatible, using the alloc crate for dynamic memory allocation.
Examples
Flowchart
Flowcharts represent workflows or processes using nodes (shapes) and edges (arrows).
For more details on the Rust implementation, check the documentation for FlowchartBuilder, FlowchartNodeBuilder, FlowchartEdgeBuilder, and Flowchart.
For more information about the Mermaid syntax, please refer to the Mermaid Flowchart documentation.
use *;
Output:
flowchart LR
v0@{shape: rect, label: "Start"}
v1@{shape: rect, label: "End"}
v0 ---> v1
Class Diagram
Class diagrams describe the structure of a system by showing classes, their attributes, methods, and relationships.
For more details on the Rust implementation, check the documentation for ClassDiagramBuilder, ClassNodeBuilder, ClassEdgeBuilder, and ClassDiagram.
For more information about the Mermaid syntax, please refer to the Mermaid Class Diagram documentation.
use *;
Output:
---
config:
class:
hideEmptyMembersBox: "false"
---
classDiagram
direction LR
class v0["Animal"] {
}
class v1["Dog"] {
}
v0 --|> v1
Entity Relationship Diagram
Entity Relationship (ER) diagrams model entities and the relationships between them. They are commonly used to design database schemas.
For more details on the Rust implementation, check the documentation for ERDiagramBuilder, ERNodeBuilder, EREdgeBuilder, and ERDiagram.
For more information about the Mermaid syntax, please refer to the Mermaid Entity Relationship Diagram documentation.
use *;
Output:
---
config:
layout: dagre
theme: default
look: classic
---
erDiagram
direction LR
v0["CUSTOMER"]
v1["ORDER"]
v0 }|--|{ v1 : ""
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.