poka.sh

Docs

D2

Generated by scripts/gen-format-pages.py from docs/data/format-metadata/, FILE_FORMATS.csv and docs/formats-master.csv. Do not edit by hand: change the source, then run the script.

D2 Preview.

At a glance

Purpose A D2 diagram source: a text description of shapes, connections and containers that the D2 tool lays out and draws.
Extensions .d2
Poka parser poka-d2
Viewer poka-metadata-card-viewer
Depth tier Metadata card (see Depth tiers)
Breadth tier B4 Summary (see Breadth tiers)

How much Poka reads

B4 Summary. The container and metadata are read and summarised (counts, properties, structure), but the main content is not rendered.

Confidence: medium (the reviewer read the code). Basis: Reviewed 2026-10-26: read parsers/poka-d2/src/main.rs (218 lines) and plugin.json in full. The crate has no unit tests and no tests/samples.rs, and the corpus has no .d2 sample, so the tier rests on reading the code. Covers .d2. The output is a metadata card of counts found by matching text line by line: arrows and bidirectional arrows, links, containers and the maximum nesting depth, shape declarations, classes and vars blocks, layers, scenarios and steps, style properties, grid declarations, SQL-table and class shapes, imports and line counts. Judgement: B4, because the structure is summarised but the source itself is never shown.

What Poka does not read

  • The source text is not shown: the card carries only counts and a few sample names, with no code view or highlighting
  • Constructs are found by matching text line by line, not by parsing, so multi-line declarations, nested or indented definitions and keywords inside strings or comments can be miscounted
  • Files over 32 MiB are cut to the first 32 MiB (the card says so)
  • Text that is not UTF-8 is decoded with replacement characters; no other encoding is tried
  • The diagram is not laid out or drawn

Libraries

Libraries Poka uses or has assessed for this format, with the status, licence and language the registry records.

  • d2 (d2parser / d2ast) (candidate; MPL-2.0; Go; https://github.com/d2lang/d2) — Reference implementation has d2parser and d2ast packages and a 'D2 as a library' section; parser API not documented on the page.
  • tree-sitter-d2 (candidate; MIT; JavaScript/C; https://github.com/ravsii/tree-sitter-d2) — Community grammar targeting D2 v0.7.0; described as not finished but usable.

Sources

  • parsers/poka-d2/src/main.rs
  • parsers/poka-d2/plugin.json