Skip to content

Docstrings: shared services - #94

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

mmacy merged 2 commits into
mainfrom
docs/api-ref-services

Conversation

@mmacy

@mmacy mmacy commented Sep 14, 2026

Copy link
Copy Markdown
Owner

I rewrote the docstrings for the six shared-services files so a developer reading the published reference can write the call and use the result without opening the source. The package docstring is now the reference's front page: it says what osrlib does, then lists every module in all three layers, in the order a reader meets them, with one line each for what goes in and what comes out. The data loaders now say what each catalog is for, which kernel function takes the entry you look up, that the result is cached and frozen, and where the id index for that catalog lives. messages.py says where message codes come from and links the message-code reference. persistence.py says what a save contains, what schema_version means for someone storing documents, what replay guarantees, and why the party document you replay from has to be taken before the session starts. errors.py names which functions raise which error and separates a raised error from a rejected command. versioning.py says what each stamp answers and when to compare it.

The quickstart block in the package docstring is unchanged, so it stays byte-identical to the one in README.md, and I made no other change to README.md.

I corrected no docstring for disagreeing with the code. Two claims I checked and kept: the comment at src/osrlib/messages.py:381 said the engine always fills the quest and objective name fields, which src/osrlib/crawl/session.py:1188 does, so the fallback to ids is for events that arrive without them; and the module docstring's claim that a load and a replay of the same game reach identical state holds only when the party document predates the session, which is now stated in replay_game.

Every example is runnable and runs under the docs harness. I left the message templates in _TEMPLATES and the exception message strings untouched: they are the library's user-visible output, the golden files assert on them, and the message-code page publishes the template source as written.

uv run ruff format --check && uv run ruff check && uv run pyright && uv run pytest -q && uv run mkdocs build --strict passes: 0 pyright errors, 2279 tests passed, 73 skipped, strict build clean.

https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa

Rewrite the docstrings in osrlib/__init__.py, errors.py, versioning.py,
data/__init__.py, messages.py, and persistence.py so a developer reading the
published reference can call them without opening the source. Adds attribute
docstrings to the Language and LanguageCatalog fields so they render with prose,
and a runnable example to every loader and every public function in the services
layer.

Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
session_state no longer claims the payload shares nothing with the session: a
raw event-log entry kept for an unrecognized event type goes in by reference.
The languages field no longer claims Common comes first; the shipped file is
alphabetical by id. The persistence module docstring now attaches the condition
replay_game states, that the party document must predate the session. The data
module docstring says again that the JSON files are generated and never edited
by hand. format_message scopes its no-raise guarantee to events osrlib built.

Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
@mmacy
mmacy merged commit e808531 into main Sep 14, 2026
5 checks passed
@mmacy
mmacy deleted the docs/api-ref-services branch September 14, 2026 06:00
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