Documentation
¶
Overview ¶
Package mermaid provides parsing and conversion of Mermaid diagrams to D2.
Package mermaid provides parsing and conversion of Mermaid diagrams to D2.
Index ¶
- func NewConverter() convert.Converter
- type Actor
- type ArrowType
- type Class
- type ClassConverter
- type Converter
- type DiagramType
- type Direction
- type Document
- type Edge
- type EdgeStyle
- type FlowchartConverter
- type GroupType
- type Lexer
- type Linter
- type Message
- type MessageGroup
- type MessageStyle
- type Node
- type NodeShape
- type Parser
- type SequenceConverter
- type Subgraph
- type Token
- type TokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConverter ¶
NewConverter creates a new Mermaid converter.
Types ¶
type ClassConverter ¶
type ClassConverter struct{}
ClassConverter converts Mermaid class diagrams to DiagramSpec.
func (*ClassConverter) Convert ¶
func (c *ClassConverter) Convert(doc *Document) *generate.DiagramSpec
Convert transforms a parsed Mermaid class document into a DiagramSpec.
type Converter ¶
type Converter struct{}
Converter implements the convert.Converter interface for Mermaid diagrams.
func (*Converter) Convert ¶
func (c *Converter) Convert(source string) (*convert.ConversionResult, error)
Convert transforms Mermaid source into a DiagramSpec.
func (*Converter) Format ¶
func (c *Converter) Format() convert.SourceFormat
Format returns the source format.
type DiagramType ¶
type DiagramType string
DiagramType represents the type of Mermaid diagram.
const ( DiagramFlowchart DiagramType = "flowchart" DiagramSequence DiagramType = "sequence" DiagramClass DiagramType = "class" DiagramState DiagramType = "state" DiagramER DiagramType = "er" DiagramGantt DiagramType = "gantt" DiagramPie DiagramType = "pie" DiagramGitGraph DiagramType = "gitGraph" DiagramUnknown DiagramType = "unknown" )
type Direction ¶
type Direction string
Direction represents the layout direction.
func (Direction) ToD2Direction ¶
ToD2Direction converts Mermaid direction to D2 direction.
type Document ¶
type Document struct {
Type DiagramType
Direction Direction
Nodes []*Node
Edges []*Edge
Subgraphs []*Subgraph
// Sequence diagram specific
Actors []*Actor
Messages []*Message
Groups []*MessageGroup
// Class diagram specific
Classes []*Class
// Raw lines for diagnostics
Lines []string
}
Document represents a parsed Mermaid document.
type Edge ¶
type Edge struct {
From string
To string
Label string
Style EdgeStyle
Line int // Source line number
}
Edge represents a connection between nodes.
type FlowchartConverter ¶
type FlowchartConverter struct{}
FlowchartConverter converts Mermaid flowcharts to DiagramSpec.
func (*FlowchartConverter) Convert ¶
func (c *FlowchartConverter) Convert(doc *Document) *generate.DiagramSpec
Convert transforms a parsed Mermaid flowchart document into a DiagramSpec.
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer tokenizes Mermaid source code.
type Message ¶
type Message struct {
From string
To string
Label string
Style MessageStyle
Line int
}
Message represents a message in a sequence diagram.
type MessageGroup ¶
type MessageGroup struct {
Type GroupType
Label string
Messages []*Message
Else []*Message // For alt/else groups
Line int
}
MessageGroup represents a group of messages (alt, opt, loop, etc.).
type MessageStyle ¶
type MessageStyle string
MessageStyle represents the style of a sequence message.
const ( MessageSolid MessageStyle = "solid" MessageDashed MessageStyle = "dashed" MessageAsync MessageStyle = "async" )
type NodeShape ¶
type NodeShape string
NodeShape represents the shape of a node.
const ( ShapeRectangle NodeShape = "rectangle" ShapeRoundedRect NodeShape = "rounded" ShapeCircle NodeShape = "circle" ShapeDiamond NodeShape = "diamond" ShapeCylinder NodeShape = "cylinder" ShapeHexagon NodeShape = "hexagon" ShapeParallelogram NodeShape = "parallelogram" ShapeTrapezoid NodeShape = "trapezoid" ShapeStadium NodeShape = "stadium" ShapeSubroutine NodeShape = "subroutine" ShapeAsymmetric NodeShape = "asymmetric" ShapeDouble NodeShape = "double" )
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses Mermaid source code into an AST.
type SequenceConverter ¶
type SequenceConverter struct{}
SequenceConverter converts Mermaid sequence diagrams to DiagramSpec.
func (*SequenceConverter) Convert ¶
func (c *SequenceConverter) Convert(doc *Document) *generate.DiagramSpec
Convert transforms a parsed Mermaid sequence document into a DiagramSpec.
type Subgraph ¶
type Subgraph struct {
ID string
Label string
Direction Direction
Nodes []*Node
Edges []*Edge
Subgraphs []*Subgraph
Line int // Source line number
}
Subgraph represents a container in Mermaid.
type TokenType ¶
type TokenType int
TokenType represents the type of a lexical token.
const ( TokenEOF TokenType = iota TokenNewline TokenWhitespace TokenIdent TokenString // "quoted string" TokenText // Text in brackets/braces TokenArrow // -->, -.->. ==>, etc. TokenPipe // | TokenColon // : TokenSemicolon // ; TokenOpenParen // ( TokenCloseParen // ) TokenOpenBrace // { TokenCloseBrace // } TokenOpenBracket // [ TokenCloseBracket // ] TokenComment // %% comment TokenDirective // %%{...}%% )