From 1ad65704682e1831459d03a59fe74aedd7a02320 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Thu, 5 Nov 2026 19:34:00 +0100 Subject: [PATCH] fix: drop BIOS files from app-only emulator titles A profile whose every file comes with the app was titled " BIOS files" and described by its system alone. The title now reads " emulator" and the description says every file it reads comes with the app. --- scripts/generate_site.py | 20 ++++++++++++++++++-- tests/test_site_search.py | 14 ++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/scripts/generate_site.py b/scripts/generate_site.py index eef11d4f8..169842b1d 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -2445,7 +2445,7 @@ def _browser_title(relative: Path, title: str) -> str: # The words a web search for a console or an emulator types: "dreamcast # bios", "duckstation bios". The h1 and the sidebar keep the name. if key.startswith("emulators/"): - has_files = PAGE_DATA.get(key, {}).get("hasPart") + has_files = PAGE_DATA.get(key, {}).get("hasPart") and key not in NOTHING_TO_FETCH # Lexaloffle, QEMU and ScummVM name a system page too. own = " emulator" if f"systems/{relative.name}" in PAGE_DATA else "" return f"{title}{own} BIOS files" if has_files else f"{title} emulator" @@ -2555,6 +2555,8 @@ def _emulator_description(markdown: str, key: str, title: str, intro: str) -> st elif title not in intro: # "It reads 1 file": the profile names no system to open on. intro = f"{title}: {intro[:1].lower()}{intro[1:]}" + if key in NOTHING_TO_FETCH: + return _shorten(f"{intro} Every file it reads comes with the app.", 155) # An alias page sends the reader to the core whose files it shares. if PAGE_DATA.get(key, {}).get("hasPart") or "uses the same firmware as" in intro: return _shorten(intro, 155) @@ -2625,6 +2627,9 @@ def _system_description(markdown: str, browser: str) -> str: # Structured data a page generator knows beyond its text, by page path # relative to docs/: read by decorate_markdown_pages. PAGE_DATA: dict[str, dict] = {} +# Emulator pages whose every file comes with the app: no "BIOS files" in +# their title, and their description says so (DaedalusX64, ZEsarUX). +NOTHING_TO_FETCH: set[str] = set() # Pages that hold part of a page too long for one (a console of a split # manufacturer, a run of an emulator's cards), by path relative to docs/: # their H1 already says what they are. @@ -2952,6 +2957,17 @@ def release_versions(profile: dict) -> dict[str, str]: if re.search(r"[0-9]", value) and not names_a_commit(value)} +def record_emulator_page(name: str, profile: dict) -> None: + """What the title and the description of an emulator page read.""" + key = f"emulators/{name}.md" + PAGE_DATA[key] = emulator_structured_data(profile) + listed = [f for f in profile.get("files") or [] if isinstance(f, dict)] + if listed and all(comes_with_app(f) for f in listed): + NOTHING_TO_FETCH.add(key) + else: + NOTHING_TO_FETCH.discard(key) + + def emulator_structured_data(profile: dict) -> dict: """What an emulator page states, for a reader of its JSON-LD. @@ -12305,7 +12321,7 @@ def _generate(args: argparse.Namespace) -> None: name, profile, db, consumers, suppl_names, data_registry, data_dirs=page_data_directories(name, profiles), ) - PAGE_DATA[f"emulators/{name}.md"] = emulator_structured_data(profile) + record_emulator_page(name, profile) # A frozen copy answers after the emulator: a frozen_snapshot, and a # profile pinned to the revision one platform builds (pin_frozen). # Reicast and Flycast 2021 LE answered "dc bios missing" before Flycast. diff --git a/tests/test_site_search.py b/tests/test_site_search.py index ca493590c..e9705738d 100644 --- a/tests/test_site_search.py +++ b/tests/test_site_search.py @@ -231,6 +231,20 @@ class Descriptions(unittest.TestCase): self.assertTrue(text.startswith("DuckStation emulates Sony PlayStation.")) self.assertNotIn("source-pinned", text) + def test_a_page_whose_files_come_with_the_app_promises_none(self) -> None: + """DaedalusX64's three files come with the app. The result read + "DaedalusX64 BIOS files" over "DaedalusX64 emulates Nintendo 64.".""" + saved, shipped = dict(gs.PAGE_DATA), set(gs.NOTHING_TO_FETCH) + self.addCleanup(lambda: (gs.PAGE_DATA.clear(), gs.PAGE_DATA.update(saved), + gs.NOTHING_TO_FETCH.clear(), gs.NOTHING_TO_FETCH.update(shipped))) + with open(REPO_ROOT / "emulators" / "daedalusx64.yml", encoding="utf-8") as handle: + gs.record_emulator_page("daedalusx64", yaml.safe_load(handle)) + key = Path("emulators/daedalusx64.md") + self.assertEqual(gs._browser_title(key, "DaedalusX64"), "DaedalusX64 emulator") + body = "# DaedalusX64\n\nDaedalusX64 emulates Nintendo 64.\n" + self.assertEqual(gs._page_description(body, key, "DaedalusX64"), + "DaedalusX64 emulates Nintendo 64. Every file it reads comes with the app.") + def test_a_console_page_is_described_by_its_start_line(self) -> None: body = "# Sega: Dreamcast\n\nPart of Sega.\n\n**Start with**: `dc_boot.bin`, `dc_flash.bin`.\n" text = gs._page_description(body, Path("systems/sega-dreamcast.md"), "Sega: Dreamcast")