[Bugfix] Doc generator/stub generator miss module-level dynamic attributes (current_scene, scenes) #356
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#356
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
mcrfpy.current_sceneandmcrfpy.scenesare real, working module attributes — confirmed live:'current_scene' in dir(mcrfpy)isFalsebuthasattr()/actual access works. They are completely absent from bothdocs/API_REFERENCE_DYNAMIC.mdandstubs/mcrfpy.pyi— a zero-hit grep forcurrent_scenein either generated artifact, despite it being the primary idiom used throughout CLAUDE.md, the tutorial series, and virtually every example script (mcrfpy.current_scene = mcrfpy.Scene("gameplay")).default_font/default_texture(real static module attributes) ARE documented correctly — this is specific to the dynamic pair.Root cause
src/McRFPy_API.cppimplements a custom moduletp_getattro/tp_setattroforcurrent_scene/scenes(issue #151, seeMcRFPy_API.cpp:129-190,api_get_current_scene/api_set_current_sceneinPySceneObject.cpp:680-723). Because these are intercepted via custom attribute hooks rather than real modulePyObjectmembers, they never appear indir(mcrfpy)— and both doc-generation tools (tools/generate_dynamic_docs.pyfor the Markdown/HTML/man reference,tools/generate_stubs_v2.pyforstubs/mcrfpy.pyi) discover module-level symbols viadir()+getattr()introspection, so both silently skip them.There is already a docstring for the concept at
McRFPy_API.cpp:355(MCRF_DESC("Module-level attribute access for dynamic properties (current_scene, scenes).")), but it's attached to the module-type slot, not to two discoverable per-attribute entries, so it doesn't get individually surfaced either.Impact
Discovered while auditing/merging generated-vs-hand-written docs on the site (mcrogueface.github.io) —
reference.md's "Module Attributes" section had to be hand-authored and hand-verified against a live binary because the generator produced nothing to draw from. This will re-drift the moment the generator is next run, since nothing about the gap is fixed at the source.Suggested direction
Either:
tp_getattro-intercepted module attributes (name + docstring + type) that bothgenerate_dynamic_docs.pyandgenerate_stubs_v2.pyconsult in addition todir()-based introspection, sourced from the existingMCRF_DESCatMcRFPy_API.cpp:355split into two real per-attribute docstrings; orcurrent_scene/scenesas real descriptor-backed module attributes (e.g. via aPyGetSetDef-style property on the module type) instead oftp_getattrostring-matching, so they become naturallydir()-discoverable and the existing introspection pipeline picks them up for free.(2) is probably the more durable fix and would also make
hasattr/dirconsistent for any future dynamic module attribute, but touches#151's existing mechanism — (1) is a smaller, generator-only patch if a C++ change isn't wanted right now.Also worth double-checking:
tools/generate_api_manifest.py(new,api/manifest.json) uses the samedir()-based introspection and will have the identical blind spot — whichever fix lands here should cover it too.