This version of the module is deprecated: Moved to moonbit-community/diago. Use moonbit-community/diago@0.4.0 or later and update import paths.
A D2-compatible diagram toolkit for MoonBit with Dagre, ELK, and Railway layout engines, rendering SVG, ASCII, and Unicode outputs.
moon update
moon buildmoon run cmd/diago -- render diagram.d2moon run cmd/diago -- --help# Render SVG (default output: input.svg)
moon run cmd/diago -- render diagram.d2
moon run cmd/diago -- render diagram.d2 diagram.svg
moon run cmd/diago -- render diagram.d2 --output diagram.svg
# Choose layout engine
moon run cmd/diago -- render --layout elk diagram.d2 diagram.svg
moon run cmd/diago -- render -l dagre diagram.d2 diagram.svg
# ASCII / Unicode text
moon run cmd/diago -- render --format ascii diagram.d2 --output diagram.ascii.txt
moon run cmd/diago -- render --format unicode diagram.d2 --output diagram.unicode.txt
# Format / validate
moon run cmd/diago -- fmt diagram.d2
moon run cmd/diago -- fmt --check diagram.d2
moon run cmd/diago -- validate diagram.d2
# Watch mode
moon run cmd/diago -- render --watch diagram.d2
# Introspection
moon run cmd/diago -- layout
moon run cmd/diago -- layout elk
moon run cmd/diago -- themes
moon run cmd/diago -- versionserver: Web Server
database: Database {
shape: cylinder
}
cache: Cache {
shape: oval
}
server -> database: queries
server -> cache: reads
cache -> database: fallbackmoon run cmd/diago -- render example.d2 example.svgD2 Source → Lexer → Parser → AST → IR → Graph → Layout (dagre/elk/railway) → Render (SVG/ASCII/Unicode)moon test # Run all tests
moon test -v # Verbose outputpub(all) suberror DiagoError {
ParseError(String)
IOError(String)
IrError(String)
GraphError(String)
LayoutError(String)
RenderError(String)
ConfigError(String)
TargetError(String)
}pub struct CompileOptions {
output_mode : OutputMode
layout_engine : LayoutEngine
direction : Direction
target_spec : String?
layout_plugin : LayoutPlugin?
route_plugin : RoutePlugin?
parse_options : ParseOptions
theme_name : String?
dark_theme_id : Int?
theme_overrides : Map[String, String]
dark_theme_overrides : Map[String, String]
scale : Double?
no_xml_tag : Bool?
salt : String?
omit_version : Bool?
}fn CompileOptions::with_dark_theme_id(self : CompileOptions, dark_theme_id : Int?) -> CompileOptionsfn CompileOptions::with_dark_theme_overrides(self : CompileOptions, dark_theme_overrides : Map[String, String]) -> CompileOptionsfn CompileOptions::with_layout_engine(self : CompileOptions, layout_engine : LayoutEngine) -> CompileOptionsfn CompileOptions::with_layout_plugin(self : CompileOptions, layout_plugin : LayoutPlugin?) -> CompileOptionsfn CompileOptions::with_output_mode(self : CompileOptions, output_mode : OutputMode) -> CompileOptionsfn CompileOptions::with_parse_options(self : CompileOptions, parse_options : ParseOptions) -> CompileOptionsfn CompileOptions::with_route_plugin(self : CompileOptions, route_plugin : RoutePlugin?) -> CompileOptionsfn CompileOptions::with_theme_overrides(self : CompileOptions, theme_overrides : Map[String, String]) -> CompileOptionspub struct CompletionItem {
label : String
kind : CompletionKind
detail : String
insert_text : String
}pub(all) enum CompletionKind {
Keyword
Style
Shape
Value
}pub(all) enum LayoutEngine {
Auto
Dagre
Elk
Railway
}#deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
fn LayoutPlugin::inner(self : LayoutPlugin) -> ((GraphInput, LayoutConfig, Direction) -> Result[GraphInput, String])fn LayoutPlugin::new(f : (GraphInput, LayoutConfig, Direction) -> Result[GraphInput, String]) -> LayoutPluginfn LayoutPlugin::run(self : LayoutPlugin, graph : GraphInput, config : LayoutConfig, direction : Direction) -> Result[GraphInput, String]pub(all) enum OutputMode {
Svg
Ascii
Unicode
}fn ParseOptions::with_import_resolver(self : ParseOptions, import_resolver : ImportResolver?) -> ParseOptions#deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
fn RoutePlugin::inner(self : RoutePlugin) -> ((GraphInput) -> Result[GraphInput, String])fn get_ref_ranges(source : String, key : String, board_path? : Array[String], options? : ParseOptions) -> Array[Range] raise DiagoErrorInstall
Download zipA D2-compatible diagram toolkit for MoonBit with Dagre, ELK, and Railway layout engines, rendering SVG, ASCII, and Unicode outputs.