tests/demo/demo_main.py died immediately on `mcrfpy.sceneUI`, removed with the
pre-Scene-object API. Four bugs, not the one filed:
1. screens/base.py called mcrfpy.sceneUI(name). The Scene object it had already
constructed owns the UI collection: scene.children.
2. demo_main.py called the removed mcrfpy.setScene().
3. run_interactive() referenced `menu`, a local of create_menu() -- NameError on
every interactive launch, independent of the sceneUI bug.
4. run_headless() assigned a DemoScreen (not a Scene) to mcrfpy.current_scene ->
TypeError, so the headless screenshot path was broken too.
The screens themselves had rotted the same way as the unit suite: add_layer() no
longer takes keyword arguments or a name (it takes a layer object), layer.set()
takes a position tuple, and mcrfpy.Animation is no longer exported (targets animate
themselves). Fixed in grid_demo and animation_demo, including the code samples the
demos display -- the demos are documentation, so a stale sample is a stale doc.
The headless path also no longer needs a Timer at all. Rendering costs zero
simulation time (#341/#350), so it just activates each scene and screenshots it,
rather than waiting for frames that headless never runs.
Six showcase scripts wrote to a hardcoded /opt/goblincorps/... absolute path outside
the repo, so they raised PermissionError for anyone else. Replaced with
tests/demo/docs_output.py: $MCRF_DOCS_REPO, else a side-by-side mcrogueface.github.io
checkout, else tests/demo/screenshots/.
The point of the issue was the gate, so: run_tests.py now runs demo_main.py as a
smoke test. Verified it catches the original bug -- reintroducing the sceneUI call
turns the demo suite red. CLAUDE.md tells newcomers to read tests/demo/screens/ for
correct API usage; nothing was checking that it ran.
The 19 standalone showcase scripts under screens/ are not on the demo_main path and
are not adopted here; follow-up issue to come.
closes #372
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
"""Where the showcase scripts write their generated images (#372).
|
|
|
|
These scripts used to hardcode /opt/goblincorps/repos/mcrogueface.github.io -- an
|
|
absolute path outside the repo, on one developer's machine. Anyone else running them
|
|
got PermissionError, which is part of why they rotted unnoticed.
|
|
|
|
Resolution order:
|
|
1. $MCRF_DOCS_REPO -- explicit checkout of mcrogueface.github.io
|
|
2. ../mcrogueface.github.io -- the usual side-by-side checkout
|
|
3. tests/demo/screenshots/ -- in-repo default, always writable
|
|
"""
|
|
import os
|
|
|
|
_HERE = os.path.dirname(os.path.abspath(__file__))
|
|
_REPO_ROOT = os.path.dirname(os.path.dirname(_HERE))
|
|
|
|
|
|
def docs_repo():
|
|
"""Root of the documentation site checkout, or None if there isn't one."""
|
|
env = os.environ.get("MCRF_DOCS_REPO")
|
|
if env and os.path.isdir(env):
|
|
return env
|
|
sibling = os.path.join(os.path.dirname(_REPO_ROOT), "mcrogueface.github.io")
|
|
if os.path.isdir(sibling):
|
|
return sibling
|
|
return None
|
|
|
|
|
|
def image_dir(*parts):
|
|
"""Directory for generated images, created if needed.
|
|
|
|
parts: subpath under the docs site's images/ (e.g. "cookbook", "tutorials").
|
|
"""
|
|
repo = docs_repo()
|
|
if repo:
|
|
target = os.path.join(repo, "images", *parts)
|
|
else:
|
|
target = os.path.join(_HERE, "screenshots", *parts)
|
|
os.makedirs(target, exist_ok=True)
|
|
return target
|