There is no reference for the binding #12

Open
opened 2026-10-23 12:52:19 +01:00 by pedro-bento · 0 comments
Owner

Summary

hate-no-d.lua is the whole public API, but the only documentation is LuaCATS comments that an
editor shows one symbol at a time. There is no browsable page, so finding a function means
grepping the 11 000-line file or reading raylib's C docs and then guessing how the wrapper
remapped the arguments.

The generator already holds every function, struct, enum and define with its description. It
writes them into Lua and throws the model away. A second renderer over the same model can emit
one self-contained hate-no-d.html at no extra parsing cost.

Current behavior

make bindings   # writes hate-no-d.lua; the model is discarded

gen-hate-no-d.lua takes a single output, --out. It builds FUNCS (928 entries),
STRUCTS (45), ALIASES (7), CALLBACKS (6), 32 enums with 421 values, and defines before
emitting anything.

Coverage in the rlparser tables:

Item Count Descriptions
Functions 928 100%
Structs and fields 45 100%
Enums and values 32 / 421 100%
Function parameters ~1400 none

Parameter prose does not exist: raylib.h carries one comment per function and nothing per
argument. The page documents parameter names and types and no more.

Two facts shape the design. First, the useful signature is the Lua one, not the C one: wrapper
signatures come from out_params(), ann_param(), ann_return() and conversion_for().
GetMousePosition() returns a Vector2; LoadImage(fileName) returns Image; callbacks and
string/table arguments are already normalised. Second, rlparser drops grouping, so the tables
alone produce a flat 928-line list.

Total text is ~85 KB. With inline CSS and JS the file lands at 250–400 KB, small enough to
commit and serve as-is.

Proposal

1. Add --html=PATH

Off by default, so --out stays byte-identical and make check-bindings keeps passing
unchanged. gen-hate-no-d.lua --html=docs/hate-no-d.html writes both files from one run.

2. Reuse the model, not the output

Render from the same tables the Lua emitter uses, and call the existing annotation helpers for
signatures. Do not parse hate-no-d.lua back: the model has module tags, struct field notes and
enum value notes that the annotations flatten.

3. Recover categories from the headers

Group by section heading, using the pinned headers the build already reads:

  • raylib.h: // Window-related functions, // Image loading functions,
    // Text drawing functions, and module banners such as
    // Basic Shapes Drawing Functions (Module: shapes)
  • rlgl.h / raymath.h: // Functions Declaration - Matrix operations,
    // Module Functions Definition - Vector3 math, ...

Scan the header in order, remember the last heading, attach it to each RLAPI/RMAPI
declaration, and fall back to the module name when no heading precedes a function. This is a
heuristic, but it reads the exact headers the binding was generated from, so a raylib bump
cannot desynchronise it.

4. Shape of the page

  • Module tabs: raylib, rlgl, raymath.
  • Category sections in header order, functions with their Lua signature and description.
  • Sections for structs, enums and defines.
  • Search box filtering on name and description.
  • Stable anchors: #InitWindow, #struct-Vector2, #enum-ConfigFlags.
  • No external requests: inline CSS and JS, relative links only, works from file://.

5. Escape in one place

Only 3 descriptions contain &, <, > or ", but every description, signature and field name
must go through a single html_escape() helper. Reuse clean_description() for whitespace.

6. Wire it into the build

make docs         # writes docs/hate-no-d.html
make check-docs   # regenerate to build/, cmp, fail on drift

check-docs mirrors check-bindings and runs in CI next to it, so the page cannot fall behind
the binding.

What stays the same

  • hate-no-d.lua output, its ordering and its byte-for-byte check.
  • make bindings and make all: no HTML unless --html is passed.
  • No new runtime dependency. The generator stays pure LuaJIT + io.

Acceptance criteria

  • make docs writes docs/hate-no-d.html from a clean tree with no network access.
  • The page opens offline and every function in hate-no-d.lua is listed exactly once.
  • Displayed signatures match the wrappers: GetMousePosition() returns Vector2,
    ImageDrawPixel takes plain numbers, LoadImage returns an optional Image.
  • Every function sits under a header-derived category, or its module name as fallback.
  • make check-docs fails when the page is stale and passes after regeneration.
  • make check-bindings still passes, and git diff after make docs is empty.

Notes

  • Determinism is trivial here: no timestamps, no hash-order iteration, version from
    RAYLIB_VERSION (currently 6.5-dev). A dated footer would break check-docs.
  • Param descriptions cannot be added without editing raylib's headers, which the project does
    not do. Leave them out rather than inventing text.
  • rlparser stores descriptions in fixed buffers (128 bytes for struct/enum fields, 512 for
    functions), so long header comments are already truncated at the source.
  • Hosting is one file, so publishing is a copy: either the site build picks up docs/, or a CI
    job uploads docs/hate-no-d.html. That choice belongs to the site, not to this issue.
  • Effort: roughly 150–250 lines in the generator (model fields, header scan, renderer), one
    Makefile target, one CI step.
## Summary `hate-no-d.lua` is the whole public API, but the only documentation is LuaCATS comments that an editor shows one symbol at a time. There is no browsable page, so finding a function means grepping the 11 000-line file or reading raylib's C docs and then guessing how the wrapper remapped the arguments. The generator already holds every function, struct, enum and define with its description. It writes them into Lua and throws the model away. A second renderer over the same model can emit one self-contained `hate-no-d.html` at no extra parsing cost. ## Current behavior ```sh make bindings # writes hate-no-d.lua; the model is discarded ``` `gen-hate-no-d.lua` takes a single output, `--out`. It builds `FUNCS` (928 entries), `STRUCTS` (45), `ALIASES` (7), `CALLBACKS` (6), 32 enums with 421 values, and defines before emitting anything. Coverage in the rlparser tables: | Item | Count | Descriptions | |---|---|---| | Functions | 928 | 100% | | Structs and fields | 45 | 100% | | Enums and values | 32 / 421 | 100% | | Function parameters | ~1400 | none | Parameter prose does not exist: `raylib.h` carries one comment per function and nothing per argument. The page documents parameter **names and types** and no more. Two facts shape the design. First, the useful signature is the Lua one, not the C one: wrapper signatures come from `out_params()`, `ann_param()`, `ann_return()` and `conversion_for()`. `GetMousePosition()` returns a `Vector2`; `LoadImage(fileName)` returns `Image`; callbacks and `string`/table arguments are already normalised. Second, rlparser drops grouping, so the tables alone produce a flat 928-line list. Total text is ~85 KB. With inline CSS and JS the file lands at 250–400 KB, small enough to commit and serve as-is. ## Proposal ### 1. Add `--html=PATH` Off by default, so `--out` stays byte-identical and `make check-bindings` keeps passing unchanged. `gen-hate-no-d.lua --html=docs/hate-no-d.html` writes both files from one run. ### 2. Reuse the model, not the output Render from the same tables the Lua emitter uses, and call the existing annotation helpers for signatures. Do not parse `hate-no-d.lua` back: the model has module tags, struct field notes and enum value notes that the annotations flatten. ### 3. Recover categories from the headers Group by section heading, using the pinned headers the build already reads: - `raylib.h`: `// Window-related functions`, `// Image loading functions`, `// Text drawing functions`, and module banners such as `// Basic Shapes Drawing Functions (Module: shapes)` - `rlgl.h` / `raymath.h`: `// Functions Declaration - Matrix operations`, `// Module Functions Definition - Vector3 math`, ... Scan the header in order, remember the last heading, attach it to each `RLAPI`/`RMAPI` declaration, and fall back to the module name when no heading precedes a function. This is a heuristic, but it reads the exact headers the binding was generated from, so a raylib bump cannot desynchronise it. ### 4. Shape of the page - Module tabs: raylib, rlgl, raymath. - Category sections in header order, functions with their Lua signature and description. - Sections for structs, enums and defines. - Search box filtering on name and description. - Stable anchors: `#InitWindow`, `#struct-Vector2`, `#enum-ConfigFlags`. - No external requests: inline CSS and JS, relative links only, works from `file://`. ### 5. Escape in one place Only 3 descriptions contain `&`, `<`, `>` or `"`, but every description, signature and field name must go through a single `html_escape()` helper. Reuse `clean_description()` for whitespace. ### 6. Wire it into the build ```sh make docs # writes docs/hate-no-d.html make check-docs # regenerate to build/, cmp, fail on drift ``` `check-docs` mirrors `check-bindings` and runs in CI next to it, so the page cannot fall behind the binding. ## What stays the same - `hate-no-d.lua` output, its ordering and its byte-for-byte check. - `make bindings` and `make all`: no HTML unless `--html` is passed. - No new runtime dependency. The generator stays pure LuaJIT + `io`. ## Acceptance criteria - [ ] `make docs` writes `docs/hate-no-d.html` from a clean tree with no network access. - [ ] The page opens offline and every function in `hate-no-d.lua` is listed exactly once. - [ ] Displayed signatures match the wrappers: `GetMousePosition()` returns `Vector2`, `ImageDrawPixel` takes plain numbers, `LoadImage` returns an optional `Image`. - [ ] Every function sits under a header-derived category, or its module name as fallback. - [ ] `make check-docs` fails when the page is stale and passes after regeneration. - [ ] `make check-bindings` still passes, and `git diff` after `make docs` is empty. ## Notes - Determinism is trivial here: no timestamps, no hash-order iteration, version from `RAYLIB_VERSION` (currently `6.5-dev`). A dated footer would break `check-docs`. - Param descriptions cannot be added without editing raylib's headers, which the project does not do. Leave them out rather than inventing text. - rlparser stores descriptions in fixed buffers (128 bytes for struct/enum fields, 512 for functions), so long header comments are already truncated at the source. - Hosting is one file, so publishing is a copy: either the site build picks up `docs/`, or a CI job uploads `docs/hate-no-d.html`. That choice belongs to the site, not to this issue. - Effort: roughly 150–250 lines in the generator (model fields, header scan, renderer), one Makefile target, one CI step.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: pedro-bento/hate-no-d#12
No description provided.