Skip to content

sparkles:twoslash

Render Twoslash type-annotation overlays on top of sparkles:syntax, in HTML, ANSI, and the raylib GUI (hue --gui).

Twoslash augments a type-checked code snippet with hover popups (type signatures), ^? queries, completion lists, compiler errors, highlighted spans, and // @tag annotation lines. This library consumes the TypeScript twoslash node model as opaque data (JSON, via sparkles:wired) and overlays it on a highlighted snippet — the render half of the D-native Twoslash umbrella (issue #120). The semantic backend that will one day replace TypeScript twoslash as the data source is sparkles:dmd-lsp (issue #124); it slots in behind the proven node model here.

Modules

ModuleRole
protocolthe flat node model (Node + NodeType + Completion + TwoslashReturn)
ingestdecode a TwoslashReturn from JSON via sparkles:wired (parseTwoslash, loadTwoslashFile)
overlaythe backend-agnostic planner (planTwoslash) + reentrant popup re-highlighter (highlightSignature)
render_htmlthe HTML overlay matching the .twoslash-* class contract
render_ansithe terminal overlay (meta-lines below the code)
stylethe ported style-rich.css (writeTwoslashStyles)

The raylib GUI backend lives in apps/hue (hue --gui --twoslash), consuming the same overlay plan.

Documentation

See also

  • sparkles:syntax — the highlight-event stream + ANSI/HTML renderers this overlays.