From 6a79281e07729d3550f9d706d197920f63ec32f2 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Fri, 6 Nov 2026 08:14:45 +0100 Subject: [PATCH] chore: read every site module in the text guards Three guards named generate_site.py or a fixed list of four modules, while page text now lives in twelve site modules and packreadme.py. The list is a glob. Read that way, the pack README said "all of theirs" twice. --- scripts/packreadme.py | 6 +++--- tests/sitepages.py | 9 +++++++++ tests/test_site_render.py | 9 +++++---- tests/test_site_validation.py | 18 +++++++++++++----- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/scripts/packreadme.py b/scripts/packreadme.py index 06ee483a3..ee5e5e26f 100644 --- a/scripts/packreadme.py +++ b/scripts/packreadme.py @@ -300,8 +300,8 @@ def _build_readme( if fallback_systems: listed = "\n".join(f" {_group_label(s)}" for s in fallback_systems) region_info += ( - "\n These systems have no BIOS in those regions, so all\n" - " of theirs were kept:\n" + "\n These systems have no BIOS in those regions, so every\n" + " BIOS file for them was kept:\n" f"{listed}\n" ) region_info += ( @@ -316,7 +316,7 @@ def _build_readme( slot_info = ( " Where a core declares which BIOS it prefers, only that one was\n" " kept for each system and region. Systems whose cores declare no\n" - " order keep all of theirs.\n" + " order keep every BIOS file.\n" ) if undecidable_slots: slot_info += ( diff --git a/tests/sitepages.py b/tests/sitepages.py index ee8897a55..f11300dd8 100644 --- a/tests/sitepages.py +++ b/tests/sitepages.py @@ -44,3 +44,12 @@ def pages() -> list[Path]: def name(path: Path) -> str: """A page file's docs path, the name tests use for it.""" return path.relative_to(CONTENT).with_suffix(".md").as_posix() + + +def generator_sources() -> list[Path]: + """Every module whose strings reach a page: generate_site.py, each + scripts/site*.py and the pack README writer. Listed by glob, so text + moved out of generate_site.py stays under the guards that read it.""" + scripts = REPO_ROOT / "scripts" + return sorted({*scripts.glob("site*.py"), scripts / "generate_site.py", + scripts / "packreadme.py"}) diff --git a/tests/test_site_render.py b/tests/test_site_render.py index f4b11a4ac..9628bd5ed 100644 --- a/tests/test_site_render.py +++ b/tests/test_site_render.py @@ -50,15 +50,16 @@ class EveryPageAddressesPlatformsAsPeers(unittest.TestCase): text every site generator writes, docstrings and bare identifiers aside.""" WORDS = ("their file", "theirs", "of ours", "corrected", "left out", "drift") - SOURCES = ("generate_site.py", "siterender.py", "sitesources.py", "siteexports.py") - def test_no_page_text_judges_another_project(self): import ast import re + from tests.sitepages import generator_sources + found = [] - for name in self.SOURCES: - tree = ast.parse((REPO_ROOT / "scripts" / name).read_text(encoding="utf-8")) + for source in generator_sources(): + name = source.name + tree = ast.parse(source.read_text(encoding="utf-8")) docstrings = { id(node.body[0].value) for node in ast.walk(tree) if isinstance(node, (ast.Module, ast.ClassDef, ast.FunctionDef, diff --git a/tests/test_site_validation.py b/tests/test_site_validation.py index feac2d14a..e7ec40fb4 100644 --- a/tests/test_site_validation.py +++ b/tests/test_site_validation.py @@ -349,9 +349,13 @@ class TheSitemapIsAnnouncedWhereCrawlersLook(unittest.TestCase): config = (root / "website" / "astro.config.mjs").read_text() self.assertIn("site: SITE", config) self.assertIn("sitemap.xml", config) - source = (root / "scripts" / "generate_site.py").read_text() - self.assertNotIn('"robots.txt"),\n "User-agent', source) - self.assertNotIn("Sitemap: https://", source) + from tests.sitepages import generator_sources + + for path in generator_sources(): + source = path.read_text(encoding="utf-8") + with self.subTest(module=path.name): + self.assertNotIn('"robots.txt"),\n "User-agent', source) + self.assertNotIn("Sitemap: https://", source) @@ -409,8 +413,12 @@ class PlainHouseStyle(unittest.TestCase): def test_headings_do_not_repeat_the_site_name(self): # The header bar already names the site, and the browser title gets # it from the theme: "# DuckStation - RetroBIOS" said it twice. - source = (ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8") - self.assertNotRegex(source, r'"# [^"]* - (?:\{SITE_NAME\}|RetroBIOS)') + from tests.sitepages import generator_sources + + for path in generator_sources(): + with self.subTest(module=path.name): + self.assertNotRegex(path.read_text(encoding="utf-8"), + r'"# [^"]* - (?:\{SITE_NAME\}|RetroBIOS)') for page in sorted((ROOT / "wiki").glob("*.md")): first = page.read_text(encoding="utf-8").splitlines()[0] with self.subTest(page=page.name):