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
@@ -800,7 +800,7 @@ class DocsDescribeTheRegistriesTheyName(unittest.TestCase):
tools = (REPO_ROOT / "wiki" / "tools.md").read_text(encoding="utf-8")
line = next(entry for entry in tools.splitlines() if "NODEDUP_DIRS" in entry)
# Compared as list items: `mame` was missing while the substring
# test found it in `_mame_clones.json` on the same line.
# test found it in `mame_clones.json` on the same line.
listed = line.split("`NODEDUP_DIRS`", 1)[1].split(":", 1)[1].rstrip(" |")
self.assertEqual(
sorted(item.strip() for item in listed.split(",")),
+4 -4
View File
@@ -550,7 +550,7 @@ class GeneratedModelsAreWrittenWhole(unittest.TestCase):
archive.writestr("rom.bin", b"rom")
data = (bios / "Arcade" / "MAME" / "set.zip").read_bytes()
(bios / "Arcade" / "MAME" / "setclone.zip").write_bytes(data)
(root / "_mame_clones.json").write_text("<<<<<<< HEAD")
(root / "mame_clones.json").write_text("<<<<<<< HEAD")
from model.database import CloneMapUnreadable
with self.assertRaises(CloneMapUnreadable):
@@ -564,11 +564,11 @@ class GeneratedModelsAreWrittenWhole(unittest.TestCase):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
(root / "bios").mkdir()
(root / "_mame_clones.json").write_text("<<<<<<< HEAD")
(root / "mame_clones.json").write_text("<<<<<<< HEAD")
with self.assertRaises(database.CloneMapUnreadable) as caught:
database.get_mame_clone_map(str(root / "bios"))
self.assertIn("Restore it from git", str(caught.exception))
(root / "_mame_clones.json").write_text("[]")
(root / "mame_clones.json").write_text("[]")
with self.assertRaises(database.CloneMapUnreadable):
database.get_mame_clone_map(str(root / "bios"))
@@ -765,7 +765,7 @@ class AMameCloneNameIsANameStep(unittest.TestCase):
bios.mkdir(parents=True)
parent = bios / "parent.zip"
parent.write_bytes(b"PARENTSET")
(self.tmp / "_mame_clones.json").write_text(
(self.tmp / "mame_clones.json").write_text(
json.dumps({"parent.zip": {"clones": ["clone.zip"]}})
)
sha1 = hashlib.sha1(parent.read_bytes()).hexdigest()
+3 -3
View File
@@ -248,7 +248,7 @@ class CloneMapSurvivesASecondRun(_Bios):
def _map(self) -> dict:
import json
path = Path(self._tmp.name) / "_mame_clones.json"
path = Path(self._tmp.name) / "mame_clones.json"
return json.loads(path.read_text()) if path.exists() else {}
def test_the_map_is_written_beside_the_scanned_tree_not_the_cwd(self):
@@ -256,7 +256,7 @@ class CloneMapSurvivesASecondRun(_Bios):
The map was written to the working directory. The test suite runs
from the repo root, so a fixture scan of a temporary tree rewrote the
committed _mame_clones.json with two fixture entries, and a later
committed mame_clones.json with two fixture entries, and a later
rewrite left 2 of its 71 parents.
"""
elsewhere = Path(self._tmp.name) / "elsewhere"
@@ -265,7 +265,7 @@ class CloneMapSurvivesASecondRun(_Bios):
self.write("Arcade/MAME/bbc_m87.zip")
self.write("Arcade/MAME/bbc_24bbc.zip")
self.run_dedup()
self.assertFalse((elsewhere / "_mame_clones.json").exists())
self.assertFalse((elsewhere / "mame_clones.json").exists())
self.assertIn("bbc_m87.zip", self._map())
def test_a_recorded_mapping_survives_a_later_run(self):
+1 -1
View File
@@ -189,7 +189,7 @@ CONTRIBUTOR_PAGES = (
REPO_DIRS = (
"scripts/", "platforms/", "emulators/", "schemas/", "tests/", "wiki/", "install/",
"provenance/", "recipes/", "exports/", "measurements/", "website/", "automation/",
"ports/", "docs_assets/", "docs/", "campaign/",
"ports/", "docs/", "campaign/",
)
PLACEHOLDER = re.compile(r"[<>*{}]|myplatform|\bNAME\b|\.\.\.")
+1 -1
View File
@@ -62,7 +62,7 @@ class SuiteWithoutJsonschema(unittest.TestCase):
# Tools a maintainer runs by hand when a logo or a card changes. Their output
# is committed under docs_assets/ and the build only reads it, so the build
# is committed under website/assets/ and the build only reads it, so the build
# keeps to the standard library and pyyaml.
MAINTENANCE_TOOLS = {
"sitegen/imagenormalize.py": "PIL",
+109
View File
@@ -0,0 +1,109 @@
"""The repository's root says what each of its entries is and which files are generated.
The directory map of the architecture page left out games/, packaging/,
measurements/ and four root data files, and README.md and CONTRIBUTING.md
gave no sign that a generator writes them.
"""
from __future__ import annotations
import tests
import re
import subprocess
import unittest
from pathlib import Path
import yaml
from core.generated import GENERATED
from sitegen.readme import GENERATED_MARKER
REPO_ROOT = Path(__file__).resolve().parent.parent
# Named by the map, never tracked: written by a run.
UNTRACKED = {"data/", "dist/", ".cache/"}
def _tracked_root() -> set[str]:
listed = subprocess.run(
["git", "ls-files", "-z"], cwd=REPO_ROOT, capture_output=True, check=True,
).stdout.decode("utf-8").split("\0")
return {
path.split("/", 1)[0] + ("/" if "/" in path else "")
for path in listed if path
}
def _map_block() -> str:
page = (REPO_ROOT / "wiki" / "architecture.md").read_text(encoding="utf-8")
section = page.split("## Directory structure", 1)[1]
return section.split("```", 2)[1]
class TheMapNamesEveryRootEntry(unittest.TestCase):
def setUp(self) -> None:
if not (REPO_ROOT / ".git").exists():
self.skipTest("not a git checkout")
def test_every_tracked_root_entry_is_in_the_map(self):
names = set(re.findall(r"[\w.-]+/?", _map_block()))
self.assertEqual(sorted(_tracked_root() - names), [])
def test_every_root_entry_of_the_map_exists(self):
named = {word.split("/", 1)[0] + ("/" if "/" in word else "")
for word in (line.split()[0] for line in _map_block().splitlines()
if line and not line[0].isspace())}
self.assertEqual(sorted(named - _tracked_root() - UNTRACKED), [])
class GeneratedFilesAreMarked(unittest.TestCase):
def test_gitattributes_marks_what_a_pipeline_run_writes(self):
text = (REPO_ROOT / ".gitattributes").read_text(encoding="utf-8")
marked = re.findall(r"(?m)^/(\S+)\s+linguist-generated=true$", text)
self.assertEqual(marked, list(GENERATED))
def test_readme_and_contributing_name_their_generator(self):
for name in ("README.md", "CONTRIBUTING.md"):
with self.subTest(file=name):
text = (REPO_ROOT / name).read_text(encoding="utf-8")
self.assertTrue(text.startswith(GENERATED_MARKER))
def test_a_hand_edit_fails_validation(self):
workflow = yaml.safe_load(
(REPO_ROOT / ".github" / "workflows" / "validate.yml").read_text(encoding="utf-8"))
on = workflow.get("on", workflow.get(True))
for event in ("pull_request", "push"):
with self.subTest(event=event):
self.assertLessEqual({"README.md", "CONTRIBUTING.md"}, set(on[event]["paths"]))
runs = [str(step.get("run", "")) for job in workflow["jobs"].values()
for step in job["steps"]]
self.assertIn(
"python scripts/generate_readme.py --db database.json --platforms-dir platforms --check",
runs)
def test_the_check_names_a_hand_edit(self):
import io
from contextlib import redirect_stdout
from tempfile import TemporaryDirectory
from unittest import mock
from sitegen import readme
with TemporaryDirectory() as tmp:
root = Path(tmp)
paths = {"README_PATH": root / "README.md", "CONTRIBUTING_PATH": root / "CONTRIBUTING.md"}
with mock.patch.multiple(readme, **paths):
with redirect_stdout(io.StringIO()):
readme.write_readme("body\n")
out = io.StringIO()
with redirect_stdout(out):
self.assertEqual(readme.check_readme("body\n"), 0)
paths["README_PATH"].write_text(GENERATED_MARKER + "edited\n", encoding="utf-8")
with redirect_stdout(out):
self.assertEqual(readme.check_readme("body\n"), 1)
self.assertIn("README.md differs", out.getvalue())
self.assertNotIn("CONTRIBUTING.md differs", out.getvalue())
if __name__ == "__main__":
unittest.main()
+1 -1
View File
@@ -302,7 +302,7 @@ class Picker(unittest.TestCase):
UNBROKEN = WEBSITE / "src" / "plugins" / "ec-unbroken-tokens.mjs"
LOGOS = REPO_ROOT / "docs_assets" / "logos"
LOGOS = REPO_ROOT / "website" / "assets" / "logos"
# Shown at 40 px in a tile and beside a setup's title: twice that for a
# sharp mark on a dense screen.
+1 -1
View File
@@ -28,7 +28,7 @@ from sitegen import starlight as sitestarlight
ROOT = Path(__file__).resolve().parent.parent
DEMO = ROOT / "docs_assets" / "demo"
DEMO = ROOT / "website" / "assets" / "demo"
COMPONENT = ROOT / "website" / "src" / "components" / "InstallDemo.astro"
+7 -7
View File
@@ -141,7 +141,7 @@ class NoMermaidAtRuntime(unittest.TestCase):
class ImagesAreServedFromTheSite(unittest.TestCase):
def _manifest(self, folder: str) -> list[dict]:
path = ROOT / "docs_assets" / folder / "sources.json"
path = ROOT / "website" / "assets" / folder / "sources.json"
return json.loads(path.read_text(encoding="utf-8"))["images"]
def test_every_registry_logo_has_a_local_copy(self):
@@ -155,13 +155,13 @@ class ImagesAreServedFromTheSite(unittest.TestCase):
with self.subTest(platform=name):
self.assertIn(name, copies, "run scripts/fetch_site_images.py --only logos")
self.assertEqual(copies[name]["source"], entry["logo"])
self.assertTrue((ROOT / "docs_assets" / "logos" / copies[name]["file"]).is_file())
self.assertTrue((ROOT / "website" / "assets" / "logos" / copies[name]["file"]).is_file())
self.assertTrue(copies[name]["owner"] and copies[name]["licence"])
def test_every_recorded_icon_exists(self):
for entry in self._manifest("system-icons"):
with self.subTest(icon=entry["file"]):
self.assertTrue((ROOT / "docs_assets" / "system-icons" / entry["file"]).is_file())
self.assertTrue((ROOT / "website" / "assets" / "system-icons" / entry["file"]).is_file())
def test_remote_links_with_a_copy_are_rewritten(self):
logo = self._manifest("logos")[0]
@@ -195,10 +195,10 @@ class SharingCards(unittest.TestCase):
for section in ogcards.OG_SECTIONS:
with self.subTest(section=section):
data = (ROOT / "docs_assets" / "og" / f"{section}.png").read_bytes()
data = (ROOT / "website" / "assets" / "og" / f"{section}.png").read_bytes()
self.assertEqual(data[:8], b"\x89PNG\r\n\x1a\n")
self.assertEqual(struct.unpack(">II", data[16:24]), (1200, 630))
mark = (ROOT / "docs_assets" / "brand" / "logo.svg").read_text(encoding="utf-8")
mark = (ROOT / "website" / "assets" / "brand" / "logo.svg").read_text(encoding="utf-8")
ET.fromstring(ogcards.og_card_svg(section, mark))
def test_the_template_names_every_section(self):
@@ -210,14 +210,14 @@ class SharingCards(unittest.TestCase):
self.assertEqual(named, set(ogcards.OG_SECTIONS))
for section in named:
with self.subTest(section=section):
self.assertTrue((ROOT / "docs_assets" / "og" / f"{section}.png").is_file())
self.assertTrue((ROOT / "website" / "assets" / "og" / f"{section}.png").is_file())
class ImagesStillNeeded(unittest.TestCase):
"""Screens that need a real device are listed, never drawn as a mock-up."""
def test_the_list_gives_each_capture_its_alt_text(self):
text = (ROOT / "docs_assets" / "images-needed.md").read_text(encoding="utf-8")
text = (ROOT / "wiki" / "images-wanted.md").read_text(encoding="utf-8")
entries = re.findall(r"(?m)^## ", text)
self.assertGreater(len(entries), 3)
self.assertEqual(len(entries), len(re.findall(r"(?m)^\*\*Alt text\*\*", text)))
+1 -1
View File
@@ -92,7 +92,7 @@ class PlatformLogos(unittest.TestCase):
tiles = {re.sub(r"[^a-z0-9]+", "-", tile.name.lower()).strip("-"): tile.logo
for group in group_tiles().values() for tile in group}
sources = json.loads((REPO_ROOT / "docs_assets" / "logos" / "sources.json").read_text())
sources = json.loads((REPO_ROOT / "website" / "assets" / "logos" / "sources.json").read_text())
for entry in sources["images"]:
with self.subTest(platform=entry["platform"]):
logo = (self.registry[entry["platform"]].get("logo")
+1 -1
View File
@@ -285,7 +285,7 @@ class PlatformShareCards(unittest.TestCase):
def test_every_platform_page_shares_its_own_card(self):
for key in list_registered_platforms(str(REPO_ROOT / "platforms")):
with self.subTest(platform=key):
card = REPO_ROOT / "docs_assets" / "og" / "platforms" / f"{key}.png"
card = REPO_ROOT / "website" / "assets" / "og" / "platforms" / f"{key}.png"
data = card.read_bytes()
self.assertEqual(struct.unpack(">II", data[16:24]), (1200, 630))
self.assertEqual(sitestarlight.og_image(f"platforms/{key}.md", "setup"),
+2 -2
View File
@@ -26,7 +26,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
class IconsComeFromTheLocalCopies(unittest.TestCase):
"""Icons were checked against upstream with a HEAD request per system on
every build, and linked from a branch tip. The build now reads the copies
in docs_assets/system-icons and makes no request."""
in website/assets/system-icons and makes no request."""
def setUp(self) -> None:
self.addCleanup(runlinks.use, runlinks.current())
@@ -35,7 +35,7 @@ class IconsComeFromTheLocalCopies(unittest.TestCase):
def test_availability_is_the_folder(self):
tmp = tempfile.TemporaryDirectory()
self.addCleanup(tmp.cleanup)
folder = Path(tmp.name) / "docs_assets" / "system-icons"
folder = Path(tmp.name) / "website" / "assets" / "system-icons"
folder.mkdir(parents=True)
(folder / "A - One.png").write_bytes(b"png")
with mock.patch.object(runlinks, "ICON_DIR", folder):
+2 -2
View File
@@ -598,10 +598,10 @@ class EachManufacturerHasItsCard(unittest.TestCase):
def test_every_manufacturer_page_has_a_committed_card(self) -> None:
cards = ogcards.system_cards()
missing = [key for key in cards
if not (REPO_ROOT / "docs_assets" / "og" / f"{key}.png").is_file()]
if not (REPO_ROOT / "website" / "assets" / "og" / f"{key}.png").is_file()]
self.assertEqual(missing, [], "run python scripts/make_og_cards.py --only systems")
# A card left behind by a page that went: oric.png outlived its page.
committed = (REPO_ROOT / "docs_assets" / "og" / "systems").glob("*.png")
committed = (REPO_ROOT / "website" / "assets" / "og" / "systems").glob("*.png")
stale = sorted(f"systems/{path.stem}" for path in committed
if f"systems/{path.stem}" not in cards)
self.assertEqual(stale, [])