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.
This commit is contained in:
Abdessamad Derraz committed 2026-11-24 10:40:25 +01:00
1 parent 5e306ec19f
commit ab7e300c19
283 files changed
+410 -193

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
"""Merging and writing the MAME clone map _mame_clones.json."""
"""Merging and writing the MAME clone map mame_clones.json."""
from __future__ import annotations
+1 -1
View File
@@ -18,7 +18,7 @@ def database_record(files: dict, indexes: dict, bios_dir: str) -> dict:
"generated_at": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"total_files": len(files),
"total_size": sum(entry["size"] for entry in files.values()),
# The tree these paths belong to: dedup writes _mame_clones.json
# The tree these paths belong to: dedup writes mame_clones.json
# beside it, and the resolver reads the map there, not at the repo root.
"bios_dir": os.path.normpath(bios_dir),
"files": files,
+14 -10
View File
@@ -41,6 +41,18 @@ def json_text(value: object) -> str:
return str(value)
def content_differs(
path: str, content: str, normalize: Callable[[str], str] | None = None
) -> bool:
"""Whether path is absent or holds other content once timestamp lines are stripped."""
if not os.path.exists(path):
return True
with open(path) as f:
existing = f.read()
before, after = (normalize(existing), normalize(content)) if normalize else (existing, content)
return _strip_timestamps(before) != _strip_timestamps(after)
def write_if_changed(
path: str, content: str, normalize: Callable[[str], str] | None = None
) -> bool:
@@ -54,16 +66,8 @@ def write_if_changed(
part it owns. Without it the second pass always sees a difference, the
file is rewritten, and the fresh timestamp defeats the comparison.
"""
if os.path.exists(path):
with open(path) as f:
existing = f.read()
before, after = (
(normalize(existing), normalize(content))
if normalize
else (existing, content)
)
if _strip_timestamps(before) == _strip_timestamps(after):
return False
if not content_differs(path, content, normalize):
return False
write_text_atomic(path, content)
return True
+1 -1
View File
@@ -12,7 +12,7 @@ Two types of deduplication:
2. MAME DEVICE CLONES: Different filenames with identical content in the same
MAME directory (e.g., bbc_m87.zip and bbc_24bbc.zip are identical ZIPs).
These are NOT aliases: MAME loads each by its unique name. Instead of
deleting, we create a _mame_clones.json mapping so generate_pack.py can
deleting, we create a mame_clones.json mapping so generate_pack.py can
pack all names from a single canonical file.
After dedup, run generate_db.py --force to rebuild database indexes.
+2
View File
@@ -40,6 +40,8 @@ STEPS: tuple[Step, ...] = (
Step("ruff check .", "the lint rules of pyproject.toml", needs="ruff",
provider='pip install -e ".[dev]"'),
Step("python scripts/build_installer.py --check", "install.py is the one installer/ builds"),
Step("python scripts/generate_readme.py --db database.json --platforms-dir platforms --check",
"README.md and CONTRIBUTING.md are the generated ones", env={"RETROBIOS_OFFLINE": "1"}),
Step("python scripts/profile_sync.py --added --strict", "each profile the branch adds"),
Step("vermin --no-tips -t=3.8- --violations install.py installer", "the installer stays on Python 3.8",
needs="vermin", provider="the pip line of CONTRIBUTING.md"),
+1 -1
View File
@@ -4,7 +4,7 @@
The site served these from other hosts: GitHub avatars and files on the
``master`` branch of upstream repositories. A rename upstream broke an image
in silence, and every page view hit third-party hosts. This tool copies them
into ``docs_assets/logos/`` and ``docs_assets/system-icons/``, which are
into ``website/assets/logos/`` and ``website/assets/system-icons/``, which are
committed, and records where each came from in a ``sources.json`` beside
them. The site build only reads those copies (``sitegen.pageprep.localize_images``).
+12 -1
View File
@@ -18,12 +18,21 @@ sys.path.insert(0, os.path.dirname(__file__))
from core.cli import add_repo_inputs
from model.database import load_database
from core.artifacts import repository_output_lock
from sitegen.readme import README_PATH, load_readme_inputs, render_readme, write_readme
from sitegen.readme import (
README_PATH,
check_readme,
load_readme_inputs,
render_readme,
write_readme,
)
def main() -> None:
parser = argparse.ArgumentParser(allow_abbrev=False, description="Generate slim README.md")
add_repo_inputs(parser, "db", "platforms")
parser.add_argument("--check", action="store_true",
help="exit 1 when README.md or CONTRIBUTING.md differs from what"
" the generator writes, writing nothing")
args = parser.parse_args()
import contextlib
@@ -38,6 +47,8 @@ def main() -> None:
with repository_output_lock(str(README_PATH)), contextlib.ExitStack() as held:
hold_data_dirs(held, load_data_dir_registry(args.platforms_dir))
inputs = load_readme_inputs(db, args.platforms_dir, args.db)
if args.check:
sys.exit(check_readme(render_readme(inputs)))
write_readme(render_readme(inputs))
+5 -5
View File
@@ -34,14 +34,14 @@ Everything a recording reads is local and the same on every machine:
rest of the bootstrap as the site's copy does.
- HOME is an empty folder and the prompt is "$ ".
docs_assets/demo/<stem>.tape drives VHS (github.com/charmbracelet/vhs, with
website/assets/demo/<stem>.tape drives VHS (github.com/charmbracelet/vhs, with
ttyd, ffmpeg and a Chromium on PATH, and bwrap for the handheld). This
script encodes what it records:
docs_assets/demo/install.gif the README (the default variant only)
docs_assets/demo/<stem>.webm the site, with <stem>.mp4 as fallback
docs_assets/demo/<stem>.png the first frame shown, the video's poster
docs_assets/demo/demo.json per variant, what it shows and its alt text
website/assets/demo/install.gif the README (the default variant only)
website/assets/demo/<stem>.webm the site, with <stem>.mp4 as fallback
website/assets/demo/<stem>.png the first frame shown, the video's poster
website/assets/demo/demo.json per variant, what it shows and its alt text
The site build copies the video files and never runs this script. Run it
again when a screen of the installer or the file list of its games changes:
+1 -1
View File
@@ -3,7 +3,7 @@
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 ``docs_assets/og/``. The site build copies the PNG files and
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.
+1 -1
View File
@@ -11,7 +11,7 @@ four pins per side and the pixel glyph on a 4 by 4 grid. Three variants:
shapes rasterised by a headless Chromium through Playwright, for browsers
that take no SVG icon and for home-screen shortcuts.
The files land in ``docs_assets/brand/``, which generate_site.py copies into
The files land in ``website/assets/brand/``, which generate_site.py copies into
the site. The site build never runs this script.
The repository's own images come from the same shapes, in ``.github/assets/``:
+3 -3
View File
@@ -161,7 +161,7 @@ _mame_clone_map_cache: dict[str, dict[str, str]] = {}
class CloneMapUnreadable(SourceUnreadable):
"""_mame_clones.json exists but is not a JSON object."""
"""mame_clones.json exists but is not a JSON object."""
def clone_map_path(bios_dir: str) -> str:
@@ -171,7 +171,7 @@ def clone_map_path(bios_dir: str) -> str:
relative to the working directory let a scan of a fixture tree rewrite
the repository's own map.
"""
return os.path.join(os.path.dirname(os.path.abspath(bios_dir)), "_mame_clones.json")
return os.path.join(os.path.dirname(os.path.abspath(bios_dir)), "mame_clones.json")
def read_clone_map(clone_path: str) -> dict:
@@ -195,7 +195,7 @@ def read_clone_map(clone_path: str) -> dict:
def get_mame_clone_map(bios_dir: str | None = None) -> dict[str, str]:
"""The MAME clone map (clone_name -> canonical_name) of a scanned tree.
dedup.py writes _mame_clones.json beside the tree it scanned, and the
dedup.py writes mame_clones.json beside the tree it scanned, and the
map of one tree says nothing about another: read from the repository
root whatever ``--bios-dir`` said, an alternate tree's renamed clones
fell out of its packs. Without a tree the repository's own is read.
+1 -1
View File
@@ -8,7 +8,7 @@ from typing import Any
from core.paths import REPO_ROOT
OUT = REPO_ROOT / "docs_assets" / "brand"
OUT = REPO_ROOT / "website" / "assets" / "brand"
PROJECT = REPO_ROOT / ".github" / "assets"
HEADER = "#3b3f7a"
+3 -3
View File
@@ -140,12 +140,12 @@ def _write_public_assets(docs: Path, public: Path) -> None:
images_dest = public / "assets" / "images"
images_dest.mkdir(parents=True, exist_ok=True)
# Logos, system icons and sharing cards are served from the site itself
# (docs_assets/*/sources.json records where each came from).
# (website/assets/*/sources.json records where each came from).
# brand: the mark, favicons and touch icon (scripts/make_site_icons.py).
folders = [("logos", "logos"), ("system-icons", "system-icons"), ("og", "og"),
("brand", "brand")]
for folder, dest in folders:
source = Path("docs_assets") / folder
source = Path("website", "assets") / folder
if source.is_dir():
shutil.copytree(source, public / "assets" / dest, dirs_exist_ok=True)
# The diagrams and the drawn install steps, one SVG per layout and theme.
@@ -154,7 +154,7 @@ def _write_public_assets(docs: Path, public: Path) -> None:
demo_dest = public / "assets" / "demo"
demo_dest.mkdir(parents=True, exist_ok=True)
for name in DEMO_ASSETS:
shutil.copy2(Path("docs_assets") / "demo" / name, demo_dest / name)
shutil.copy2(Path("website", "assets") / "demo" / name, demo_dest / name)
assets_src = Path(".github") / "assets"
for name, dest_name in [("logo.png", "logo.png"), ("favicon.png", "favicon.png")]:
src = assets_src / name
+1 -1
View File
@@ -122,7 +122,7 @@ def _coverage_inputs(db_path: Path, platforms_dir: str, emulators_dir: str) -> s
revisions = sorted({REPO_ROOT / versions_file_for(entry)
for entry in load_data_dir_registry(platforms_dir).values()
if entry.get("local_cache")})
for path in (REPO_ROOT / ".gitignore", REPO_ROOT / "_mame_clones.json", *revisions):
for path in (REPO_ROOT / ".gitignore", REPO_ROOT / "mame_clones.json", *revisions):
add_file(path)
digest.update(b"offline\0" + (b"1" if run_is_offline() else b"0") + b"\n")
large = Path(LARGE_FILES_CACHE).resolve()
+1 -1
View File
@@ -8,7 +8,7 @@ from pathlib import Path
from core.paths import REPO_ROOT
OUT = REPO_ROOT / "docs_assets" / "demo"
OUT = REPO_ROOT / "website" / "assets" / "demo"
WORK = REPO_ROOT / "tmp" / "demo"
FACTS = OUT / "demo.json"
+1 -1
View File
@@ -143,7 +143,7 @@ def first_screen_words() -> list[str]:
f"and **{installer.TUI_FOLDER_TITLE}**), then offers **{installer.TUI_INSTALL_ROW}**."]
# The demo files the site serves (docs_assets/demo/, scripts/make_demo.py):
# The demo files the site serves (website/assets/demo/, scripts/make_demo.py):
# the GIF is the README's, the tape and demo.json are inputs.
DEMO_ASSETS = tuple(f"{stem}.{ext}" for stem in ("install", "install-handheld")
for ext in ("webm", "mp4", "png"))
+1 -1
View File
@@ -1,4 +1,4 @@
"""The platform logos and system icons the site shows, copied once into docs_assets/."""
"""The platform logos and system icons the site shows, copied once into website/assets/."""
from __future__ import annotations
+4 -4
View File
@@ -17,8 +17,8 @@ from model.platforms import load_platform_config
from model.registry import list_registered_platforms
from sitegen.diagrams import FONT, setups_named, wrap
OUT = REPO_ROOT / "docs_assets" / "og"
LOGO = REPO_ROOT / "docs_assets" / "brand" / "logo.svg"
OUT = REPO_ROOT / "website" / "assets" / "og"
LOGO = REPO_ROOT / "website" / "assets" / "brand" / "logo.svg"
PLATFORM_TAGLINE = "Which BIOS files it needs, and where each one goes"
# The tagline's box on the card: og_card_svg wraps it at this width and
# size, and three lines fit above the address.
@@ -26,7 +26,7 @@ TAGLINE_WIDTH, TAGLINE_SIZE, TAGLINE_LINES = 1000, 34, 3
# Sharing cards: one 1200x630 card per section of the site, rendered to PNG
# once by scripts/make_og_cards.py and committed under docs_assets/og/.
# once by scripts/make_og_cards.py and committed under website/assets/og/.
OG_SECTIONS: dict[str, tuple[str, str]] = {
"home": ("BIOS and firmware packs", "Checked file by file, for {frontends}"),
@@ -40,7 +40,7 @@ OG_SECTIONS: dict[str, tuple[str, str]] = {
def og_card_svg(section: str, mark_svg: str) -> str:
"""A sharing card. ``mark_svg`` is the site's white mark
(docs_assets/brand/logo.svg), drawn as the header draws it."""
(website/assets/brand/logo.svg), drawn as the header draws it."""
title, tagline = OG_SECTIONS[section]
tagline = tagline.format(frontends=setups_named(["RetroArch", "Batocera", "EmuDeck"]))
mark = mark_svg.strip().replace("<svg ", '<svg x="96" y="88" width="112" height="112" ', 1)
+2 -2
View File
@@ -46,8 +46,8 @@ def unresolved_images(markdown: str) -> list[str]:
# Local copies of images the site used to load from other hosts.
LOGO_DIR = REPO_ROOT / "docs_assets" / "logos"
ICON_DIR = REPO_ROOT / "docs_assets" / "system-icons"
LOGO_DIR = REPO_ROOT / "website" / "assets" / "logos"
ICON_DIR = REPO_ROOT / "website" / "assets" / "system-icons"
SITE_LOGO_DIR = "assets/logos"
SITE_ICON_DIR = "assets/system-icons"
IMAGE_LINK = re.compile(r"(!\[[^\]\n]*\]\()(https?://[^)\s]+)(\))")
+31 -12
View File
@@ -14,7 +14,7 @@ from core.text import series
from romrecipes import ledger
from devtools import prchecks
from model import releaserecord, siteinputs
from core.artifacts import write_if_changed
from core.artifacts import content_differs, write_if_changed
from core.paths import DB_FILE, REPO_ROOT
from core.sizes import size_text
from core import upstream
@@ -94,7 +94,7 @@ def collection_line(total_files: int, comp: dict) -> str:
# The installer demo (scripts/make_demo.py): the recording and what it shows.
DEMO_GIF = "docs_assets/demo/install.gif"
DEMO_GIF = "website/assets/demo/install.gif"
REPO = REPO_SLUG
README_PATH = REPO_ROOT / "README.md"
CONTRIBUTING_PATH = REPO_ROOT / "CONTRIBUTING.md"
@@ -372,6 +372,7 @@ def render_readme(inputs: ReadmeInputs) -> str:
f"- Have a file? [Check it by its hash]({SITE_URL}files/)",
f"- Every console and the files it needs: [systems]({SITE_URL}systems/)",
f"- Asking an AI assistant: it reads the site best from [llms.txt]({SITE_URL}llms.txt)",
f"- Screen reader, keyboard only or no colour: [accessibility]({SITE_URL}wiki/accessibility/)",
"",
"## How it is built",
"",
@@ -612,14 +613,32 @@ def generate_contributing() -> str:
)
def write_readme(readme: str) -> None:
status = "Generated" if write_if_changed(str(README_PATH), readme) else "Unchanged"
print(f"{status} ./README.md")
# The first line of both repository files: GitHub renders the comment as
# nothing, and whoever opens the file to edit it learns where the text comes from.
GENERATED_MARKER = (
"<!-- Generated by scripts/generate_readme.py from scripts/sitegen/readme.py."
" Edit the generator, then run it: a hand edit fails the Validation workflow. -->\n"
)
contributing = generate_contributing()
status = (
"Generated"
if write_if_changed(str(CONTRIBUTING_PATH), contributing)
else "Unchanged"
)
print(f"{status} ./CONTRIBUTING.md")
def readme_files(readme: str) -> dict[Path, str]:
"""README.md and CONTRIBUTING.md as the repository holds them."""
return {
Path(README_PATH): GENERATED_MARKER + readme,
Path(CONTRIBUTING_PATH): GENERATED_MARKER + generate_contributing(),
}
def check_readme(readme: str) -> int:
"""1, naming each file, when the committed text differs from the generated one."""
stale = [path.name for path, text in readme_files(readme).items()
if content_differs(str(path), text)]
for name in stale:
print(f"{name} differs from what generate_readme.py writes: run it and commit")
return 1 if stale else 0
def write_readme(readme: str) -> None:
for path, text in readme_files(readme).items():
status = "Generated" if write_if_changed(str(path), text) else "Unchanged"
print(f"{status} ./{path.name}")
+1 -1
View File
@@ -64,7 +64,7 @@ def prime_system_icons(names: set[str]) -> int:
"""Record which system icons the site holds a copy of, and return how
many of ``names`` have none.
The icons are copied once into ``docs_assets/system-icons/`` by
The icons are copied once into ``website/assets/system-icons/`` by
``scripts/fetch_site_images.py``: the build reads that folder and never
the network. A system without a copy gets no icon, because a heading
with a broken image reads worse than a heading without one.
+1 -1
View File
@@ -315,7 +315,7 @@ def og_section(rel: str, level: str) -> str:
# Sharing cards of their own, made by scripts/make_og_cards.py: one per
# platform page, titled with the platform's name.
OG_DIR = REPO_ROOT / "docs_assets" / "og"
OG_DIR = REPO_ROOT / "website" / "assets" / "og"
# An emulator page's card is that of the maker of the first system it runs,
+1 -1
View File
@@ -86,7 +86,7 @@ STEPS: dict[str, tuple[str, tuple[Step, ...]]] = {
)),
}
# The recording each tab shows (docs_assets/demo/demo.json keys), "" for none.
# The recording each tab shows (website/assets/demo/demo.json keys), "" for none.
TAB_DEMOS = {"device": "handheld", "windows": ""}
DEFAULT_DEMO = "default"