mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-06 10:03:49 -06:00
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.
This commit is contained in:
1 parent
9b871db83a
commit
6a79281e07
4 files changed
+30
-12
No files matched your search
@@ -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 += (
|
||||
|
||||
@@ -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"})
|
||||
@@ -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,
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user