ludic/tools/docgen
Orkuncakilkaya 764a0296ce
All checks were successful
bootstrap / cfree-fixpoint (push) Successful in 22s
ci / build-and-test (push) Successful in 2m4s
commit-lint / conventional-commits (push) Successful in 4s
docs / build-and-deploy (push) Successful in 28s
feat(stdlib): Tiled P6 — infinite/chunked maps, .world stitching, base64+zstd (#74)
- Infinite/chunked maps: <chunk x y width height> (TMX) and JSON chunks[]
  (default 16x16) decode and flatten into the dense layer array, sized to the
  chunk union; the map's 0/0 header dimensions fall back to the flattened bounds.
- .world stitching: Tiled.world / Tiled.world_count / Tiled.world_map read a
  .world (JSON, reusing Json.parse) and list its member maps at their offsets.
- base64+zstd: a self-contained pure-Ludic Zstandard decompressor
  (runtime/native/zstd.ludic, RFC 8878) — the design's "largest single item,
  explicitly last". Frame header + raw/RLE/compressed blocks; raw/RLE and
  direct-weight Huffman literals; the full FSE sequence path (predefined,
  transcribed exactly from zstd's hardcoded tables since they're not rebuildable
  from the default distributions; RLE; FSE-described) with repeat offsets and
  execution. Decodes the low-entropy GID streams a tilemap produces; a high-
  entropy FSE-compressed-Huffman-weights block fails cleanly with -1 rather than
  emitting wrong bytes (documented scope).

Proven by library/tiled_p6.ludic (12 assertions): TMX + TMJ chunk flattening,
.world offsets, and a real zstd-compressed tile layer decoding byte-exactly to
its CSV baseline. x test: 97 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-01 16:07:10 +03:00
..
assets docs(site): vertical pipeline on mobile, click tooltips, consistent chrome 2026-08-29 18:42:40 +03:00
inventory.json feat(stdlib): Tiled P6 — infinite/chunked maps, .world stitching, base64+zstd (#74) 2026-09-01 16:07:10 +03:00
README.md feat(tooling): port the docgen site generator to Ludic (no Python) (#41) 2026-08-31 02:12:32 +03:00

Ludic documentation generator

Generates the public documentation site (the pages branch) from a single source of truth, so the site can never drift from the language.

Source of truth

docs/
  language/<category>/<id>.md    one file per symbol — keyword, type, phase,
                                 builtin, namespace method, operator, annotation
  language/<category>/_section.md   section title + blurb + order
  language/colors/palette.json   the 221 named colors (generated by `x docs-palette`)
  site/site.json                 landing-page messaging (hero, features, …)
  site/snippets/*.ludic          the code shown on the landing page (real programs)
tools/docgen/inventory.json      the authoritative symbol set the coverage guard checks

A symbol file

---
id: screen-fill_rectangle     # anchor + page name (screen-fill_rectangle.html)
name: Screen.fill_rectangle
category: screen
kind: namespace-method        # keyword|type|phase|namespace-method|builtin|annotation|operator
tokens: Screen.fill_rectangle # literal token(s) the highlighter matches & links
sig: Screen.fill_rectangle(x, y, width, height, color)
tip: Draw a solid, filled rectangle.     # one sentence — the hover-card summary
order: 1
ns: Screen                    # namespace-method only
member: fill_rectangle        # namespace-method only
related: screen-clear screen-draw_rectangle
---

Rich description — inline `<code>`/`backticks`, "model instance" language.

Parameters:                   # for anything that takes arguments
- `x` — the left edge, in pixels
- `color` — the fill color, e.g. a `Color.*` name

​```ludic
program Example { … descriptive-named, compilable … }
​```

What it produces

One page per symbol (<id>.html), a namespace overview page per namespace (ns-screen.html … ns-color.html), a searchable index (api.html, fuzzy search over every symbol), the landing page (index.html), the ludic-highlight.js highlighter (all its symbol tables, tips, per-item link targets, per-parameter anchors and hover-card data generated from the sources above), symbols.json, and .nojekyll.

In any code sample: keywords/types/builtins/annotations link to their page; Screen.fill_rectangle links Screen → the namespace page and fill_rectangle → the method page separately; a named argument like width: links to that parameter's anchor; Color.Charcoal links Color and Charcoal separately; hovering any token shows a summary card from the real API data.

Build & check

The generator and its guards are written in Ludic and run through x — there is no Python in the pipeline. assets/ (the CSS/HTML/JS templates) and inventory.json are the only inputs the tools here still read directly.

bin/x docs-gen --out build/pages    # generate the whole site
bin/x docs-check build/pages        # coverage + duplicate-token + link guard
bin/x check-docs                    # parse every ```ludic doc fence

docs-check fails CI if any symbol in inventory.json lacks a page, if a token is documented on two pages, or if a highlighter link points at a missing page — so "every symbol is documented, autogenerated each time" is enforced. It needs a built bin/x (bootstrapped from the IR seed with clang alone).

Publish

.forgejo/workflows/docs.yml bootstraps the toolchain from the IR seed and runs x docs-gen + x docs-check on every push to main that touches docs/**, tools/docgen/** or tools/x/**, and publishes the result to the pages branch root. index.html + .nojekyll always stay at the root.

Colors

palette.json and selfhost/backend/stdlib/emit_color.ludic are both generated by bin/x docs-palette from a single palette table — the pal_add(...) rows in tools/x/docgen.ludic. Edit the table there and regenerate; do not hand-edit the generated files.