[PR #1581] [MERGED] Mod API reference generated from the WIT contract #3608

Closed
opened 2026-11-03 04:10:46 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1581
Author: @ludovic111
Created: 10/24/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @ludovic111

Base: main ← Head: docs/mod-api-reference


📝 Commits (1)

  • 1b23a14 Mod API reference generated from the WIT contract

📊 Changes

5 files changed (+463 additions, -0 deletions)

View changed files

📝 .gitattributes (+1 -0)
📝 crates/horizon-mod-sdk/wit/horizon.wit (+12 -0)
📝 crates/horizon-mods/Cargo.toml (+5 -0)
➕ crates/horizon-mods/tests/api_reference.rs (+304 -0)
➕ docs/api/mods-reference.md (+141 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Part of the platform plan (Horizon's APIs, documented): the first generated API reference, so the mod API's documentation can't drift from its contract.

What

  • docs/api/mods-reference.md, generated by crates/horizon-mods/tests/api_reference.rs from crates/horizon-mod-sdk/wit/horizon.wit (parsed with wit-parser, already a pack dependency) and the manifest's Capability table: the capabilities and what the player reads, each world's imports and exports, every interface with its access, types (records, enums, variants, flags), functions with their WIT signatures and doc comments, and the api lines the game serves.
  • Tests (feature pack, as CI's cargo test --workspace … --features horizon-mods/pack runs them):
    • the page is up to date (HORIZON_WRITE_DOCS=1 cargo test -p horizon-mods --features pack --test api_reference rewrites it, as the launcher reference does);
    • every function in the WIT has a doc comment;
    • every capability that grants an interface names one the contract has.
  • WIT doc comments for the functions and fields that had none (log.write, player x/y/z, pitch, health, food, get-clock, line.text, set-panel, clear, tick, frame, chat). Comments only: the contract is unchanged, and the values were checked against game/mods.rs and runtime.rs (16 HUD lines, 256 characters).
  • .gitattributes: docs/api/*-reference.md are LF everywhere, like the other generated references.

Why

Ludovic wants every API documented as the reference others copy. A reference generated from the source, with a test, is the only kind that stays true. #1189's second world and machine interface will show up in this page automatically when it lands (the generator walks every world and interface).

How tested

cargo test -p horizon-mods --features runtime,pack     # 11 + 3 + 12 (1 ignored) passed: sandbox guests rebuilt with the commented WIT
cargo clippy -p horizon-mods --features runtime,pack --all-targets -- -D warnings   # clean
cargo fmt --check                                      # clean

Parity: tools/parity.py --changed-files maps these files to all 334 harnesses (unmapped paths default to all); none of the harnesses loads a mod or reads the WIT, and the change is comments plus a test, so none were run locally.

Needs Ludovic

Nothing. Merge order with the other two platform PRs: this one and the server reference first, then the portal.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/1581 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `docs/mod-api-reference` --- ### 📝 Commits (1) - [`1b23a14`](https://github.com/horizon-rust/horizon/commit/1b23a14ee706cf0464dba0a138f21dcbe551075b) Mod API reference generated from the WIT contract ### 📊 Changes **5 files changed** (+463 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `.gitattributes` (+1 -0) 📝 `crates/horizon-mod-sdk/wit/horizon.wit` (+12 -0) 📝 `crates/horizon-mods/Cargo.toml` (+5 -0) ➕ `crates/horizon-mods/tests/api_reference.rs` (+304 -0) ➕ `docs/api/mods-reference.md` (+141 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Part of the platform plan (Horizon's APIs, documented): the first generated API reference, so the mod API's documentation can't drift from its contract. ## What - **`docs/api/mods-reference.md`**, generated by `crates/horizon-mods/tests/api_reference.rs` from `crates/horizon-mod-sdk/wit/horizon.wit` (parsed with `wit-parser`, already a `pack` dependency) and the manifest's `Capability` table: the capabilities and what the player reads, each world's imports and exports, every interface with its access, types (records, enums, variants, flags), functions with their WIT signatures and doc comments, and the `api` lines the game serves. - **Tests** (feature `pack`, as CI's `cargo test --workspace … --features horizon-mods/pack` runs them): - the page is up to date (`HORIZON_WRITE_DOCS=1 cargo test -p horizon-mods --features pack --test api_reference` rewrites it, as the launcher reference does); - every function in the WIT has a doc comment; - every capability that grants an interface names one the contract has. - **WIT doc comments** for the functions and fields that had none (`log.write`, `player` x/y/z, pitch, health, food, `get-clock`, `line.text`, `set-panel`, `clear`, `tick`, `frame`, `chat`). Comments only: the contract is unchanged, and the values were checked against `game/mods.rs` and `runtime.rs` (16 HUD lines, 256 characters). - `.gitattributes`: `docs/api/*-reference.md` are LF everywhere, like the other generated references. ## Why Ludovic wants every API documented as the reference others copy. A reference generated from the source, with a test, is the only kind that stays true. #1189's second world and `machine` interface will show up in this page automatically when it lands (the generator walks every world and interface). ## How tested ``` cargo test -p horizon-mods --features runtime,pack # 11 + 3 + 12 (1 ignored) passed: sandbox guests rebuilt with the commented WIT cargo clippy -p horizon-mods --features runtime,pack --all-targets -- -D warnings # clean cargo fmt --check # clean ``` Parity: `tools/parity.py --changed-files` maps these files to all 334 harnesses (unmapped paths default to all); none of the harnesses loads a mod or reads the WIT, and the change is comments plus a test, so none were run locally. ## Needs Ludovic Nothing. Merge order with the other two platform PRs: this one and the server reference first, then the portal. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:10:46 +07:00
Sign in to join this conversation.
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
horizon-rust/horizon#3608
No description provided.