Skip to content

Docstrings: crawl session and events - #99

Merged
mmacy merged 2 commits into
mainfrom
docs/api-ref-crawl-session-events
Sep 14, 2026
Merged

Docstrings: crawl session and events#99
mmacy merged 2 commits into
mainfrom
docs/api-ref-crawl-session-events

Conversation

@mmacy

@mmacy mmacy commented Sep 14, 2026

Copy link
Copy Markdown
Owner

A developer reading the published reference can now run a game from the session page alone: build one with GameSession.new, execute a typed command, read the result envelope, render the events, read state through a view, and save. Every public method answers what it does, what it needs first, what to call next, and what to use instead, and new, execute, view, and the listener protocol each carry an example I ran. The public instance attributes of GameSession (the mode, the logs, the flags, the journal, the quest states, the exploration counters) each have a docstring now, so the page no longer shows a column of bare names.

Every crawl event class says when it fires, which command emits it, what each message code in its set means, and who may see it, and every field has an attribute docstring. That covers the generated pages under reference/events/, whose body is the class docstring plus the schema.

Two corrections where the code disagreed with the docstring. HoardGeneratedEvent said cache_ref is "the engine-created cache's state reference (or the group id for carried bundles)"; the only emission site (src/osrlib/crawl/exploration.py:3024, inside _generate_cache) always passes the allocated cache id, so the field now says that (src/osrlib/crawl/events.py:1137). MonsterFledEvent declares battle.side.surrendered in its code set, and nothing in the engine sets EncounterGroup.surrendered or emits that code, so the code set now says which code the engine emits and that a game adjudicating a surrender itself can use the other (src/osrlib/crawl/events.py:1033). That looks like a gap in the battle resolution rather than a docstring problem, so I left the code alone.

No block is marked no-run, and I left nothing undocumented that the reference renders.

https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa

GameSession is the entry point of the library for anyone running a game, and
its docstrings now carry the whole path a front end takes: build a session with
new, execute a typed command, read the result, render the events, read state
through a view, and save. Every public method says what it does, what you need
first, what to call next, and what to use instead, with runnable examples on
new, execute, view, and the listener protocol.

Every crawl event class says when it fires, which command emits it, what each
of its message codes means, and who may see it, and every field of every event
has an attribute docstring, so the generated event pages and the API reference
describe an event without the reader opening the source.

Docstrings and comments only: no signature, default, field, or behavior
changed.

Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
The noise_since_check docstring said failing to force a door sets the flag, but
_handle_force_door sets it before the roll, so any attempt past the gate sets it
whether the door opens or not. A failed attempt is what alerts the area beyond,
which is the part that denies the party surprise there.

Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant