polish: discovery hardening per code review (review round 2 minors)

- Fail fast with clear RuntimeError when themes/ directory is missing
- Document underscore-prefix skip rule
- Tests: broken-manifest/mismatch/no-manifest skip case, missing-dir fail-fast
- tests/test_theme_pro_v3.py: drop fourth hardcoded list, import from core

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-10-22 17:28:57 +08:00
parent 204c5039ab
commit b1b4d12a19
4 changed files with 28 additions and 3 deletions
+5 -1
View File
@@ -13,8 +13,12 @@ ROOT = Path(__file__).resolve().parent.parent
def discover_themes():
"""Discover built-in themes from themes/*/manifest.json (single source of truth)."""
themes_dir = ROOT / 'themes'
if not themes_dir.is_dir():
raise RuntimeError(f'themes directory missing: {themes_dir}')
found = []
for entry in sorted((ROOT / 'themes').iterdir()):
for entry in sorted(themes_dir.iterdir()):
# Underscore prefix marks non-theme assets (e.g. _professional_components.html).
if not entry.is_dir() or entry.name.startswith('_'):
continue
try: