ludic/tools/docgen
Orkuncakilkaya dd4f5a26ad
All checks were successful
docs / build-and-deploy (push) Successful in 2s
feat(stdlib): add Fs.* / Path.* / Mime.* — filesystem, paths, content types (#10)
A cohesive filesystem & IO library — the foundation for saves, config, mods, and
asset loading — wrapping the bare file_* builtins into one safe, ergonomic API a
non-expert can use without touching a file descriptor or a byte buffer.

  Path.*  join / dir / base / ext / stem / normalize   (pure lexical string ops)
  Fs.*    exists / is_dir / read_text / write_text / append_text / remove /
          size / mkdir / copy / list
  Mime.*  of (extension table) / sniff (magic bytes: PNG/JPEG/GIF/PDF)

Pure string IR for Path.*; libc (fopen/access/mkdir/rename/opendir…) for Fs.*;
C-free, emitted on demand (g_uses_fsrt). Safety and determinism baked in:
- write_text and copy are atomic (write a temp file, then rename over the target)
  so a crash mid-write never corrupts the previous file;
- mkdir creates parents (mkdir -p);
- list is sorted for a stable, reproducible directory walk;
- fallible calls return values (null / false / -1), never crashes — ready for a
  first-class try/else when the error-handling work lands.

Complements Os.* (#21): Os supplies per-user locations, Fs the operations. v1
targets the native macOS/BSD filesystem with "/" separators; Windows separators,
a sandboxed wasm virtual FS, recursive directory copy, and richer magic-byte
sniffing are documented follow-ups.

- examples/library/fs.ludic: 32 assertions across pure Path ops (incl. normalize
  resolving ./ .. and duplicate slashes), a real create/read/append/copy/list/
  remove cycle under build/, and Mime by-extension + by-magic (GIF signature vs a
  .bin extension). Wired into `x test` (now 56 passed).
- docs: new Path, Fs, and Mime sections + 18 per-symbol pages; inventory updated;
  every fence passes check-docs; site builds via docgen.
- seed regenerated; `x bootstrap-cfree` fixpoint holds.

Closes #10

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-30 22:43:50 +03:00
..
assets docs(site): vertical pipeline on mobile, click tooltips, consistent chrome 2026-08-29 18:42:40 +03:00
check-impl.py refactor(lang): rename the fn keyword to function 2026-08-30 01:43:22 +03:00
check.py docs: merge duplicate networking namespace dirs; guard against recurrence 2026-08-30 16:46:21 +03:00
gen.py feat(stdlib): namespaced standard library (issue #2) 2026-08-30 00:26:19 +03:00
inventory.json feat(stdlib): add Fs.* / Path.* / Mime.* — filesystem, paths, content types (#10) 2026-08-30 22:43:50 +03:00
palette.py refactor(lang): rename the fn keyword to function 2026-08-30 01:43:22 +03:00
README.md docs(api): per-symbol pages, fuzzy search, deep token linking, hover cards 2026-08-29 17:53:22 +03:00
validate.py refactor(lang): rename the fn keyword to function 2026-08-30 01:43:22 +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 palette.py)
  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

python3 tools/docgen/gen.py --out build/pages    # generate the whole site
python3 tools/docgen/check.py build/pages         # coverage + duplicate-token + link guard
python3 tools/docgen/validate.py                  # compile every ```ludic example with bin/ludicc

check.py 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. validate.py needs a built bin/ludicc; the deploy CI is Python-only, so run it locally or in a toolchain-enabled job.

No third-party dependencies — Python standard library only.

Publish

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

Colors

palette.json is generated by tools/docgen/palette.py from a single PALETTE table, which also generates selfhost/emit_color.ludic. Regenerate colors there.