Skip to content

vox-diagram API Reference (generated)

Crate: vox-diagram · Version: 0.6.0 · Target: Library (lib.rs)

Pure VoxDiagram core: graph DSL lexer, error-recovering parser, resolved IR, diagnostics with machine-applicable fixes, canonical formatter, markdown fence scanner, dagre graph layout and a deterministic SVG renderer.

VoxDiagram core: graph and sequence DSL lexer, error-recovering parser, resolved IR, diagram/* diagnostics with machine-applicable fixes, canonical formatter, markdown fence scanner, graph layout and deterministic SVG rendering of both kinds. Pure and synchronous: no I/O, no async runtime, no workspace dependencies.

graph {
node a: "A"
node b: "B"
a -> b
}
ModuleDescription
astSyntax tree produced by the parser.
codesStable diagram/* diagnostic codes.
diagDiagnostics, fixes and the check report.
fenceMarkdown fenced-block scanner shared by every diagram consumer.
irResolved serialisable diagram IR.
limitsNamed input caps.
mermaidMermaid export (verified against a pinned real Mermaid parser) and strict, fail-closed Mermaid import.
sequence_irSequence diagram IR types, the payload of Ir::Sequence.
spanByte spans and line/col locations.
svgDeterministic, injection-safe, themeable SVG rendering of graph and sequence diagrams (graph layout through the dagre adapter).
validateOne-call validation envelope (check, canonical form, optional Mermaid import and SVG/Mermaid emit) shared by the MCP tool and the CLI.
ConstantDescription
GRAMMAR_CARDThe VoxDiagram grammar card (graph and sequence) for agent authoring guidance. It is appended to the vox_validate_diagram MCP tool description and published verbatim in docs/src/reference/vox-diagram.md; tests/grammar_card.rs keeps the two in sync.
Dependency Topology, diagram 13 nodes, 2 edges: vox-doc-pipeline → vox-diagram; vox-orchestrator-mcp → vox-diagramvox-diagramvox-doc-pipelinevox-orchestrator-mcp
Diagram source
graph {
direction: right
node vox_diagram: "vox-diagram"
node vox_doc_pipeline: "vox-doc-pipeline"
vox_doc_pipeline -> vox_diagram
node vox_orchestrator_mcp: "vox-orchestrator-mcp"
vox_orchestrator_mcp -> vox_diagram
}
Consumer CrateRole
vox-doc-pipelineDirect workspace dependent
vox-orchestrator-mcpDirect workspace dependent
KindSymbolSignatureSourceDescription
enumast::DiagramKindpub enum DiagramKindcrates/vox-diagram/src/ast.rs#L11-L17Which diagram kind a document’s header names.
structast::Documentpub struct Documentcrates/vox-diagram/src/ast.rs#L21-L32A parsed graph { ... } or sequence { ... } document, with the comments around it.
structast::Commentpub struct Commentcrates/vox-diagram/src/ast.rs#L40-L47A // comment. blank_before follows the same rule as [Item::blank_before].
structast::Blockpub struct Blockcrates/vox-diagram/src/ast.rs#L51-L58Ordered entries of a { ... } block.
enumast::Entrypub enum Entrycrates/vox-diagram/src/ast.rs#L62-L67One block entry.
structast::Itempub struct Itemcrates/vox-diagram/src/ast.rs#L71-L81A statement plus its trivia.
enumast::ItemKindpub enum ItemKindcrates/vox-diagram/src/ast.rs#L85-L100Statement kinds.
structast::ActorDeclpub struct ActorDeclcrates/vox-diagram/src/ast.rs#L104-L109A sequence actor declaration.
structast::MessageStmtpub struct MessageStmtcrates/vox-diagram/src/ast.rs#L113-L122A sequence message.
structast::NoteStmtpub struct NoteStmtcrates/vox-diagram/src/ast.rs#L126-L131A sequence note over one or two actors.
structast::DirectionStmtpub struct DirectionStmtcrates/vox-diagram/src/ast.rs#L135-L140direction: <down|right|up|left>.
structast::ContainerDeclpub struct ContainerDeclcrates/vox-diagram/src/ast.rs#L144-L155A container declaration with its nested body.
structast::NodeDeclpub struct NodeDeclcrates/vox-diagram/src/ast.rs#L159-L169A node declaration.
structast::EdgeStmtpub struct EdgeStmtcrates/vox-diagram/src/ast.rs#L173-L180An edge statement.
structast::Refpub struct Refcrates/vox-diagram/src/ast.rs#L184-L192A dotted reference such as backend.gateway.
structast::Bracketpub struct Bracketcrates/vox-diagram/src/ast.rs#L196-L207Mermaid id[Label] text where a plain id belongs: it declares the node (M3).
structast::Identpub struct Identcrates/vox-diagram/src/ast.rs#L211-L216An identifier.
structast::Labelpub struct Labelcrates/vox-diagram/src/ast.rs#L220-L225A decoded quoted label.
enumdiag::Severitypub enum Severitycrates/vox-diagram/src/diag.rs#L14-L19How serious a diagnostic is. valid means “no Error”.
structdiag::Fixpub struct Fixcrates/vox-diagram/src/diag.rs#L23-L28One text edit; all fixes of a diagnostic form a single atomic remedy.
structdiag::Relatedpub struct Relatedcrates/vox-diagram/src/diag.rs#L32-L37A secondary location that explains a diagnostic.
structdiag::Diagnosticpub struct Diagnosticcrates/vox-diagram/src/diag.rs#L41-L59A stable, span-precise problem report.
structdiag::Statspub struct Statscrates/vox-diagram/src/diag.rs#L182-L191Size counters of a checked document. For a sequence, nodes counts actors, edges counts events (messages plus notes) and containers and max_depth are 0.
structdiag::CheckReportpub struct CheckReportcrates/vox-diagram/src/diag.rs#L195-L207Result of [crate::check].
structfence::Fencepub struct Fencecrates/vox-diagram/src/fence.rs#L13-L22One fenced code block whose info string matched.
fnfence::extractpub fn extract(md: &str, info: &str) -> Vec<Fence>crates/vox-diagram/src/fence.rs#L25-L49Every fenced block in md whose trimmed info string equals info exactly.
fnfence::normalizepub fn normalize(body: &str) -> Stringcrates/vox-diagram/src/fence.rs#L76-L81CRLF and lone CR to LF, then trailing whitespace trimmed (Rust half of the manifest key).
enumir::Irpub enum Ircrates/vox-diagram/src/ir.rs#L12-L17Resolved diagram: a graph or a sequence diagram.
enumir::Directionpub enum Directioncrates/vox-diagram/src/ir.rs#L22-L32Flow direction of a graph.
enumir::Shapepub enum Shapecrates/vox-diagram/src/ir.rs#L37-L51Node shape.
structir::GraphIrpub struct GraphIrcrates/vox-diagram/src/ir.rs#L55-L64A resolved graph.
structir::IrNodepub struct IrNodecrates/vox-diagram/src/ir.rs#L68-L81A resolved node.
structir::IrContainerpub struct IrContainercrates/vox-diagram/src/ir.rs#L85-L98A resolved container.
structir::IrEdgepub struct IrEdgecrates/vox-diagram/src/ir.rs#L102-L111A resolved edge between two node ids.
structmermaid::ImportOptspub struct ImportOptscrates/vox-diagram/src/mermaid/mod.rs#L33-L36Options for [import].
structmermaid::Unsupportedpub struct Unsupportedcrates/vox-diagram/src/mermaid/mod.rs#L40-L45A construct the importer did not accept (or dropped), with its block-relative line.
structmermaid::ImportReportpub struct ImportReportcrates/vox-diagram/src/mermaid/mod.rs#L50-L63Result of [import]. Invariant, for every diagram kind: source.is_some() exactly when unsupported is empty (the import failed closed otherwise, and sequence is None too).
structsequence_ir::SequenceIrpub struct SequenceIrcrates/vox-diagram/src/sequence_ir.rs#L9-L14A sequence diagram: declared actors and the ordered events between them.
structsequence_ir::Actorpub struct Actorcrates/vox-diagram/src/sequence_ir.rs#L18-L25A participant lane.
enumsequence_ir::SeqEventpub enum SeqEventcrates/vox-diagram/src/sequence_ir.rs#L30-L53One event on the timeline.
structspan::Spanpub struct Spancrates/vox-diagram/src/span.rs#L7-L12Half-open byte range start..end into the original source.
structspan::Locationpub struct Locationcrates/vox-diagram/src/span.rs#L16-L29A [Span] plus 1-based line/col (col counted in Unicode scalar values).
structsvg::SvgOptspub struct SvgOptscrates/vox-diagram/src/svg/mod.rs#L19-L25Options for [render].
enumsvg::RenderErrorpub enum RenderErrorcrates/vox-diagram/src/svg/mod.rs#L38-L55Why a diagram could not be rendered.
fnsvg::renderpub fn render(ir: &Ir, opts: &SvgOpts) -> Result<String, RenderError>crates/vox-diagram/src/svg/mod.rs#L107-L109Render ir to an SVG document. Synchronous, with no timeout: graph layout is super-quadratic in the number of ranks an edge spans, and a structured diagram at the render caps can take several seconds. Call it off the request path. A sequence diagram has no layout engine: it renders in time linear in actors times events.