graphviz.mbt is a MoonBit rewrite of Graphviz focused on strict output parity for the dot pipeline.
The repository currently targets byte-for-byte compatibility with upstream Graphviz 14.1.1 fixtures for:
dotxdotsvg
This project is built as a multi-package MoonBit module and includes a native dot-style CLI, a DOT parser/writer, layout code, and renderers.
The project is under active development. The main engineering goal is not just "similar rendering", but reproducible Graphviz-compatible behavior backed by strict fixtures and regression guards.
Today the repository includes:
- a native CLI frontend at
src/cmd/dot - DOT parsing and writing
- DOT layout implementation in MoonBit
- XDOT and SVG renderers
- strict parity tests against upstream Graphviz reference outputs
The top-level parity contract is intentionally narrow: fixture expectations are authored from upstream Graphviz 14.1.1, not from this repository's own binary.
- MoonBit with the
moonCLI - a native toolchain supported by
moon --target native - Python 3 for some repository scripts
- upstream Graphviz
14.1.1when refreshing parity fixtures
For fixture authoring and refreshes, use an external Graphviz 14.1.1 binary such as:
/opt/homebrew/opt/graphviz@14.1.1/bin/dot/usr/local/opt/graphviz@14.1.1/bin/dot
Do not generate parity fixtures with this repository's own dot.exe.
Build the native CLI:
moon build src/cmd/dot --target nativeRun it on a DOT file:
_build/native/debug/build/cmd/dot/dot.exe -Tsvg input.gv -o output.svgWrite layout-annotated DOT to stdout:
_build/native/debug/build/cmd/dot/dot.exe -Tdot input.gvList currently supported output formats:
_build/native/debug/build/cmd/dot/dot.exe -TCurrent CLI coverage includes:
- output formats:
dot,xdot,svg - frontend behavior compatible with
dotandneatoprogram names - common flags:
-T,-K,-o,-G,-N,-E,-s,-n,-x,-v,-V
Basic local validation:
moon check --target native --deny-warn
moon test --target native --release --deny-warnBefore pushing a no-regression milestone, run the full local guard:
scripts/run_local_guard.shThat guard covers:
- the full release MoonBit test suite
- strict parity checks for
dot,xdot, andsvg - fixture/case-list invariants
DOT_CAPTURE_ORDERING_INPUTSenvironment-invariance checks
For faster parity iteration on a small focus set:
scripts/check_strict_parity.py --formats dot xdot svg --focus ldbxtried typesharStrict parity fixtures are reference artifacts, not self-generated expectations.
- The fixture source of truth is upstream Graphviz
14.1.1. - Use an external Graphviz
14.1.1binary to generate or refreshdot,xdot, andsvgfixtures. - Treat
refs/graphvizas source/input corpus and upstream code reference, not as the default fixture-authoring binary. - Do not use the repository's own
dot.exeto define expected parity outputs.
Manual snapshot regeneration helpers include:
bash scripts/generate_dot_snapshots.shbash scripts/generate_xdot_snapshots.shbash scripts/generate_svg_snapshots.shbash scripts/generate_svg_renderer_snapshots.sh
Some layout assets are intentionally pre-generated to avoid expensive pre-build steps. See:
src/layout/dot/README.mdsrc/render/xdot/README.mdsrc/render/svg/README.md
Core packages:
src/cgraph: graph data modelsrc/dot: DOT parsing and writingsrc/layout/dot: DOT layout pipelinesrc/render/xdot: XDOT renderersrc/render/svg: SVG renderersrc/cli: CLI parsing and render pipeline orchestrationsrc/cmd/dot: native executable entrypoint
Useful documentation:
docs/parity_guard.md: strict parity workflow and history scan toolsdocs/graphviz/architecture.md: upstream Graphviz architecture notesdocs/graphviz/cli-and-formats.md: CLI and I/O format referencesrc/layout/dot/DOT_LAYOUT_ALGORITHM.md: end-to-end DOT layout pipeline notes
This project is licensed under the Eclipse Public License 2.0. See LICENSE.