Skip to content

Docstrings: crawl commands - #88

Merged
mmacy merged 3 commits into
mainfrom
docs/api-ref-crawl-commands
Sep 14, 2026
Merged

mmacy merged 3 commits into
mainfrom
docs/api-ref-crawl-commands

Conversation

@mmacy

@mmacy mmacy commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

A front-end developer reading the published reference can now build a command without opening the source. Every command field, every SessionMode member, and the three CommandResult fields used to render as a bare name and a type; each one now says what the value is, which view or loader the id comes from, and which rejection code a wrong value produces. The module docstring leads with the call path (build a command, execute it, render the events, read state through the view) and carries a runnable usage block that walks from character creation to a serialized command and back, and parse_command has an example.

The second commit puts the whole module into one register, including the docstrings the first commit did not otherwise touch. Em dashes and en dashes are gone, semicolon splices are two sentences each, the inactive to active to completed arrow chain is prose, and coined phrases like "defensive twin of the mode gate" and "salvage door" say what they mean. In the rejection and event lists only the separator changed, from an em dash to a hyphen, so the sections keep the shape the docs gates parse.

I corrected one claim while writing it. BattleDeclaration.move accepts four values, but _party_movement in battle.py (lines 1291-1333) resolves only close, fighting_withdrawal, and retreat. A withdraw declaration passes validation and then moves nobody, so I documented it that way. That looks like a defect rather than a design choice, and it is outside this batch.

I also found two comments in battle.py that disagree with the code, and left both alone: _party_movement's docstring says the first close declaration "in marching order" advances the formation, but by_member is built from command.declarations in the order they were given, so it is the first entry in the list. EncounterView.immobile in views.py says close and withdraw moves are rejected for its members, which is true but incidental, since the cannot_move check covers every move declaration.

I left the per-subclass command_type and allowed_modes overrides without docstrings on purpose. Both are documented once on Command, the rendered signature shows each subclass's literal value, and each class's Modes: section already names the modes in prose, so a docstring on all of them would be the same sentence repeated for every command.

https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa

Give every command field, enum member, and result field an attribute
docstring, so the generated reference stops rendering them as bare names.
Each one says what the value is, where a caller gets it, and what happens
when it's wrong. Rewrite the module docstring to lead with the call path
and carry a runnable usage block, and add an example to parse_command.

Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
Extend the wording pass to the docstrings the first commit didn't touch, so
the whole module reads the same way. Em dashes and en dashes are gone,
semicolon splices are two sentences, the arrow chain is prose, and the
coined phrases and tacked-on qualifiers are plain words. The rejection and
event lists keep the shape the docs gates parse; only the separator changes
from an em dash to a hyphen.

Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
The Events sections of the commands with a cascade behind them named a few
event classes and left the rest as prose, so the reader had nothing to click
through to. Trace each handler and name every class it can emit, keeping the
condition each one fires under. ResolveBattleRound's list is grouped by
phase.

Also: name the three referee commands a concluded session withholds instead
of implying the exception is a set of modes, drop a minimizer in
RevealObjective, and take the bold off a running sentence in TakeTreasure.

Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
@mmacy
mmacy merged commit 1c1656a into main Sep 14, 2026
5 checks passed
@mmacy
mmacy deleted the docs/api-ref-crawl-commands branch September 14, 2026 05:59
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