Class diagram
Parse classDiagram classes, members, direction and inheritance/composition/association relations into class boxes and relation lines.
Inputs and parameters
input— Mermaid class source
Real example
classDiagram
direction TB
class Diagram {
+String kind
+validate()
+exportSVG()
}
class StrictPolicy {
+allowDirective()
-rejectScript()
}
class ExportPlan {
+String filename
+assertNonBlankPNG()
}
Diagram <|-- Flowchart
Diagram --> StrictPolicy : filters
Diagram --> ExportPlan : emits
→ class: 4 classes / 3 relations; CJK class and member names, +/- visibility and <|-- inheritance are preserved; SVG contains class-box and relation groups.
Limits and failure handling
Only class declarations, single-line members and common relation operators are covered; namespaces are recorded but not laid out, and annotations/generics/lollipop interfaces are out of scope this run.
FAQ
What if a class block is not closed?
UNCLOSED_CLASS_BLOCK is returned at the class declaration line and the input is preserved.
Are generics supported?
This subset escapes generic characters as ordinary text without semantic parsing; real Mermaid generics rendering is untested.