Repository navigation
Docstrings: core items and treasure - #91
Merged
Merged
Conversation
Every public member of osrlib.core.items and osrlib.core.treasure, plus every model field, constant, and enum member the reference renders, now says what it does, when to call it, what to call next, and what to use instead. Id-typed parameters link their loader and the generated content-id index, the duck-typed wielder and allocator parameters name the classes that satisfy them, and the entry points carry runnable examples. Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
Every pydantic field and enum member in core/items.py and core/treasure.py now carries its own attribute docstring instead of a row in the class's Attributes table, so no member renders as a bare name. Alongside that: the equipment catalog example prints the shipped display name, the ammunition and quantity rules in the two weighing functions say what the code does, unequip states that the curse check precedes the slot search, the scroll table says which spell level it sets rather than how powerful it is, the adaptations register is linked, and the four private helpers that had no docstring have one. Claude-Session: https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I rewrote every docstring in
src/osrlib/core/items.pyandsrc/osrlib/core/treasure.pyfor someone reading the published reference who has never opened the source. A reader can now find out which member to call for equipment, inventories, magic items, encumbrance, and treasure generation, what to hand it, what comes back, and what to do with that, without leaving the page. Every pydantic field and every enum member carries its own attribute docstring, so nothing in either module renders as a bare name. Id-typed parameters link the loader inosrlib.dataand the generated content-id index that lists valid values, and the duck-typed parameters (characteronsword_control_check,allocatoron the generation functions) name the classes that satisfy them and link them, with no annotation changed. The entry points carry runnable examples, and every example in both files runs under the docs examples harness.Five docstrings were wrong about the code and are now corrected.
generate_treasure(src/osrlib/core/treasure.py) promised aValueErrorfor an unknowntier, but the tier is only read once the roll reaches a magic item, so a hoard of coins alone accepts any string;generate_treasure_entriesandgenerate_unguarded_treasurenow carry the same note, which neither had before.equipment_weight_coins(src/osrlib/core/items.py) said ammunition weighs nothing, when the code weighs an ammunition template like any other and it is the four shipped templates that are weight 0; it now says so.treasure_weight_coinsnow says a stack weighs its template's figure times its quantity, with a spent stack counting as one.unequipnow says the curse check runs before the slot search, so an item under a revealed curse reports the curse whether or not it is equipped. TheEquipmentCatalog.getexample printedTorchwhere the shipped display name isTorches (6), which is fixed, and the gear and ammunitionnamefields now say that the price list names the lot. I also dropped the count of weapons from the items module docstring, since prose counts drift as a surface grows.No example is marked
no-run. The only members without a docstring are the pydantic validators and the other underscore-prefixed helpers, which the reference hides. One thing for you to decide rather than me: the tier check is not a pure pre-check in the three generation entry points, sotier="bogus"silently produces a coins-only hoard. I documented the behavior and did not change it.https://claude.ai/code/session_01GL26QnA6dCrvUc3WmhzFSa