Files
libretro/scripts/make_og_cards.py
T
Abdessamad Derraz ab7e300c19 refactor: tidy the repository root
README.md and CONTRIBUTING.md open with a comment naming their
generator, generate_readme.py --check fails on a hand edit in
validate.yml and pr_checks.py, and .gitattributes marks the pipeline
outputs as generated, held equal to core/generated.py by a test.

_mame_clones.json becomes mame_clones.json, still written beside the
scanned bios/ tree, and now triggers both workflows (coverage reads it).
docs_assets/ moves to website/assets/, which Astro does not read as
content. ACCESSIBILITY.md becomes wiki/accessibility.md, linked from the
README and the installer page. The screenshot list moves to
wiki/images-wanted.md: nothing read docs_assets/screens/.

The architecture map names every root entry (test_repository_map),
platforms/README.md keeps only what this folder holds, the reference
index lists archive-recipes and measurements, and reference-terms no
longer defines Profile twice nor repeats the glossary's Pack.
2026-11-24 10:40:25 +01:00

45 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Render the sharing cards (Open Graph images) to PNG, once.
Each card is an SVG written by ``sitegen.ogcards.og_card_svg`` from the
registry, rasterised by a headless Chromium through Playwright, then
committed under ``website/assets/og/``. The site build copies the PNG files and
never runs this script, so it adds nothing to the build's dependencies.
Run it again when a section's wording, the platform count, the list of
platforms or the consoles of a manufacturer change.
python scripts/make_og_cards.py
python scripts/make_og_cards.py --only platforms
python scripts/make_og_cards.py --only systems
A platform page shares a card with its own name (``og/platforms/<id>.png``),
a manufacturer's systems page one with the manufacturer's name and its
consoles (``og/systems/<slug>.png``), the other pages their section's.
"""
from __future__ import annotations
import argparse
from core.paths import REPO_ROOT
from sitegen.chromium import require_playwright
from sitegen.ogcards import card_keys, card_titles, render_cards
def main() -> None:
parser = argparse.ArgumentParser(description="Render the sharing cards to PNG.",
allow_abbrev=False)
parser.add_argument("--only", choices=("sections", "platforms", "systems"),
help="render one kind of card (default: all)")
args = parser.parse_args()
sync_playwright = require_playwright()
titles = card_titles(args.only)
for path in render_cards(sync_playwright, card_keys(args.only, titles), titles):
print(path.relative_to(REPO_ROOT))
if __name__ == "__main__":
from core.cli import run_cli
run_cli(main)