diff --git a/scripts/sitegen/descriptions.py b/scripts/sitegen/descriptions.py index b5962d90b..9ef7b90b0 100644 --- a/scripts/sitegen/descriptions.py +++ b/scripts/sitegen/descriptions.py @@ -9,7 +9,6 @@ from collections.abc import Iterable from pathlib import Path from core.text import series -from model import releaserecord from sitegen import measurements as sitemeasurements from sitegen.config import SITE_NAME @@ -165,15 +164,9 @@ def page_description(markdown: str, relative: Path, title: str) -> str: def _section_description(markdown: str, relative: Path, title: str, browser: str, lead: str) -> str | None: - """The description of a download, system, emulator or platform page, - or None for a page of another section.""" + """The description of a system, emulator or platform page, or None for + a page of another section. A download page writes its own (getpages).""" key = relative.as_posix() - if key.startswith(f"{releaserecord.GET_DIR}/"): - size = re.search(r"^- (.+ to download\b.*?)\.?$", markdown, re.M) - if size: - return _shorten(f"{title}: the BIOS pack of this setup, {_plain_markdown(size[1])}. " - "The address stays the same and always gives the latest ZIP.", 155) - return _shorten(_first_paragraph(lead) or title, 155) if key.startswith("systems/") and relative.stem != "index": return _system_description(markdown, browser) if key.startswith("emulators/") and relative.stem != "index": diff --git a/tests/test_site_search.py b/tests/test_site_search.py index 62c4123c7..f690e597c 100644 --- a/tests/test_site_search.py +++ b/tests/test_site_search.py @@ -427,6 +427,20 @@ class GetPagesSitInYourSetup(unittest.TestCase): getpages.generate_get_page("retroarch") self.assertEqual(descriptions.PAGE_DATA["get/retroarch.md"], {"dateModified": "-".join(tag.groups())}) + def test_every_get_page_writes_its_own_description(self): + """getpages and handheld own the description of a download page: + page_description has no branch of its own for one.""" + from sitegen import handheld + + saved = dict(descriptions.PAGE_DATA) + self.addCleanup(lambda: (descriptions.PAGE_DATA.clear(), descriptions.PAGE_DATA.update(saved))) + pages = [getpages.generate_get_page("retroarch"), getpages.generate_get_index(), + handheld.group_page(REPO_ROOT)] + for page in pages: + front = page.split("\n---\n", 1)[0] + self.assertRegex(front, r"(?m)^description: \"[^\"]+\"$") + self.assertNotIn("GET_DIR", (REPO_ROOT / "scripts/sitegen/descriptions.py").read_text(encoding="utf-8")) + def test_no_page_is_left_out_of_every_tab(self): nav = _nav() present = _present(nav) | {"orphans/alone.md"}