docs: document the public Graphik API and drawText's center anchoring - #35
Merged
Merged
Conversation
Adds a docstring to the Graphik class and to every public method, covering the parameter contract a caller needs: coordinate anchoring, units, the repeat-fire semantics of drawButton's callback, and drawImage's path-keyed caching and raise behavior. help(Graphik) and IDE tooltips previously showed nothing, which matters most for the vendored copies of graphik.py that consumers read without the README alongside. Records in the README that drawText anchors on the center of the rendered text while drawRectangle, drawButton and drawImage anchor on their top-left corner, and pins that behavior with a test so the documented claim is enforced rather than asserted. The existing implementation comments are left untouched; they answer a maintainer's question, not a caller's. No behavior, signature or version change, so no consumer impact. Closes #32 Closes #33 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Drops the doctest prompts from the class example -- the snippet is illustrative, and `>>> pygame.init()` would fail if doctest collection were ever switched on, since init() returns a tuple the example does not show. Lists drawButton alongside drawRectangle and drawImage in drawText's anchoring note, matching the class docstring and the README rather than naming only two of the three top-left-anchored siblings. Renames a loop variable in the new anchoring test for symmetry with the line above it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
ReviewThe diff was reviewed against this repository's own conventions and validated on the PR head. Findings are folded into this comment as External anchor
Rubric
Findings raised and resolved during reviewThe first-pass diff was not accepted as-is. Three findings were raised and fixed in
Observations not blocking merge
VerdictApproved for merge. The change is additive documentation plus one characterization test, the external anchor is green across every supported interpreter, and no path on the do-not-auto-merge list is touched. This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
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.
Summary
Graphikclass and to all six public methods plus the constructor. The parameter contract a caller needs is now recorded in the source: coordinate anchoring, units,drawButton's repeat-fire callback semantics, anddrawImage's path-keyed caching and raise behavior. Before this changeinspect.getdocreturnedNonefor the class and every public method, sohelp(Graphik)and IDE tooltips were empty.drawTextnow states thatxpos/yposare the center of the rendered text, contrasted against the top-left convention used bydrawRectangle,drawButtonanddrawImage. ThedrawRectanglebullet has been given the matching top-left note so the contrast is explicit on both sides.The existing implementation comments have been left untouched — those answer a maintainer's question ("why is the font cache invalidated this way"), whereas the docstrings answer a caller's ("where does my text land"). The two are complementary.
Why the docstrings matter here specifically
graphik is consumed as a vendored copy of
graphik.pyin Roam, Apex, Ophidian, Patchwork and Tic-Tak-Toe. The README does not travel with that file, so the source itself is the only documentation a consumer developer has in front of them.Consumer impact
None. No public member has been renamed, removed, or had its signature changed; no behavior has been altered; no version string has been touched. The change is additive documentation plus one new test, so the consumer-impact gate does not apply.
Test plan
python3 -m py_compile src/main/python/preponderous/graphik/graphik.py— succeeds.SDL_VIDEODRIVER=dummy—preponderous.graphikimports and reports0.3.0.dev20260808.python3 -m pytest— 26 passed (25 before, 1 added).inspect.getdocfor the class and all seven documented members; each returns text whereNonewas returned previously.textRectangle.centertemporarily changed totextRectangle.topleft, the test fails; with the original line restored, it passes. The assertion therefore discriminates between the two anchoring conventions rather than passing vacuously.Validation was run on Python 3.8.10 with pygame 2.1.2 and pytest 7.1.3. Note that
pyproject.tomldeclaresrequires-python = ">=3.9", so the sandbox interpreter sits one minor version below the supported floor; the CI matrix in.github/workflows/test.ymlcovers 3.9 through 3.13 on this PR.Deferred this cycle
Issue #34 (release tags are pushed without the
vprefix thatpublish.ymlrequires, so the publish workflow has never run) was filed during triage and deliberately left unimplemented. It touches.github/workflows/and the release process, and the choice between correcting the tagging practice and broadening the workflow trigger is a maintainer decision rather than an autonomous one.Closes #32
Closes #33
This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson