P4: gitea-renderable parity-gallery-grid.md (markdown with inline images)

Gitea serves raw .html with Content-Type: text/plain for security, so the
HTML gallery only renders via `open` locally or external static hosting.
Add a parallel markdown version that gitea's /src/ view renders natively
with inline images.

View: https://gitea.treytartt.com/admin/honeyDueKMP/src/branch/rc/android-ios-parity/docs/parity-gallery-grid.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Trey T
2026-04-18 23:59:06 -05:00
parent 031d61157f
commit 3944223a5e
3 changed files with 576 additions and 6 deletions

View File

@@ -25,7 +25,8 @@ import sys
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ANDROID_DIR = "composeApp/src/androidUnitTest/roborazzi"
IOS_DIR = "iosApp/HoneyDueTests/__Snapshots__/SnapshotGalleryTests"
OUT = "docs/parity-gallery.html"
OUT_HTML = "docs/parity-gallery.html"
OUT_MD = "docs/parity-gallery-grid.md"
# swift-snapshot-testing names files "test_<func>.<name>.png" — strip prefix
IOS_NAME_RE = re.compile(r"^test_[^.]+\.(.+)\.png$")
@@ -63,13 +64,51 @@ def parse_key(key: str) -> tuple[str, str, str]:
return key, "?", "?"
def write_markdown(android: dict[str, str], ios: dict[str, str], screens: list[str]) -> None:
"""Emit a gitea-renderable grid as markdown tables.
Gitea serves .html as text/plain (security), but renders .md natively at
its /src/ URL with inline images. This output is the browser-viewable one.
"""
out = os.path.join(REPO_ROOT, OUT_MD)
os.makedirs(os.path.dirname(out), exist_ok=True)
# Markdown image paths are relative to the .md file, which lives in docs/.
# We already compute relative-to-docs paths in load(); those apply here too.
with open(out, "w", encoding="utf-8") as f:
f.write("# honeyDue parity gallery\n\n")
f.write(f"*{len(android)} Android · {len(ios)} iOS · {len(screens)} screens*\n\n")
f.write("Auto-generated by `scripts/build_parity_gallery.py` — do not hand-edit.\n\n")
f.write("See [parity-gallery.md](parity-gallery.md) for the workflow guide.\n\n")
f.write("## Screens\n\n")
for s in screens:
f.write(f"- [{s}](#{s.replace('_', '-')})\n")
f.write("\n---\n\n")
for screen in screens:
anchor = screen.replace("_", "-")
f.write(f"## {screen}<a id='{anchor}'></a>\n\n")
f.write("| State / Mode | Android | iOS |\n")
f.write("|---|---|---|\n")
for state in ("empty", "populated"):
for mode in ("light", "dark"):
key = f"{screen}_{state}_{mode}"
a = android.get(key)
i = ios.get(key)
a_cell = f"![]({a})" if a else "_missing_"
i_cell = f"![]({i})" if i else "_missing_"
f.write(f"| **{state}** / {mode} | {a_cell} | {i_cell} |\n")
f.write("\n[top](#honeydue-parity-gallery)\n\n---\n\n")
print(f"wrote {OUT_MD}")
def main() -> int:
android = load("android", ANDROID_DIR)
ios = load("ios", IOS_DIR)
keys = sorted(set(android) | set(ios))
screens = sorted({parse_key(k)[0] for k in keys})
out_path = os.path.join(REPO_ROOT, OUT)
write_markdown(android, ios, screens)
out_path = os.path.join(REPO_ROOT, OUT_HTML)
os.makedirs(os.path.dirname(out_path), exist_ok=True)
with open(out_path, "w", encoding="utf-8") as f:
f.write(PAGE_HEAD)
@@ -111,7 +150,7 @@ def main() -> int:
f.write("</div>\n")
f.write(PAGE_FOOT)
print(f"wrote {OUT}: {len(screens)} screens, {len(android)} Android + {len(ios)} iOS images")
print(f"wrote {OUT_HTML}: {len(screens)} screens, {len(android)} Android + {len(ios)} iOS images")
return 0