diff --git a/scripts/generate_site.py b/scripts/generate_site.py index 461cadd0a..731dee433 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -3401,20 +3401,14 @@ def _served_line(f: dict) -> str: f"(sha1 `{sha1[:8]}`)") -# Platforms whose launcher records are read from the repository and revision -# of their BIOS list: batocera_scraper reads configgen at its tag, -# retrobat_scraper reads emulatorLauncher at the list's commit -# (launcher_revision). The others read another repository. -_LAUNCHERS_IN_LIST_REPO = frozenset({"batocera", "retrobat"}) - - -def _launcher_refs(platform: str, config: dict) -> dict[str, list[str]]: +def _launcher_refs(config: dict) -> dict[str, list[str]]: """Entry name, casefolded -> each launcher record that opens it, rendered.""" from launchers import _names as launcher_names from sitesources import launcher_ref_markdown, list_source - source = (list_source(str(config.get("source") or "")) - if platform in _LAUNCHERS_IN_LIST_REPO else None) + # Every scraper reads its launchers in the repository and at the revision + # of the list it scrapes, so `source` pins each source_ref. + source = list_source(str(config.get("source") or "")) found: dict[str, list[str]] = {} for record in config.get("launchers") or []: if not isinstance(record, dict) or not record.get("source_ref"): @@ -3626,7 +3620,7 @@ def _render_platform_systems( # Per-system detail sections (collapsible for large platforms) use_collapsible = len(by_system) > 10 by_system_declared = _declared_by_system(config_files) - launched = _launcher_refs(platform[0] if platform else "", config or {}) + launched = _launcher_refs(config or {}) sections: list[dict] = [] for sys_id, files in sorted(by_system.items()): diff --git a/tests/test_site_r2_reference.py b/tests/test_site_r2_reference.py index 4a12df33e..24eb2c4b5 100644 --- a/tests/test_site_r2_reference.py +++ b/tests/test_site_r2_reference.py @@ -129,13 +129,32 @@ class EvidenceLinksItsSource(unittest.TestCase): evidence = {"read_by": [{"emulator": "launcher", "proof": "launcher", "entries": [], "runs_system": True}]} config = load_platform_config("batocera", PLATFORMS) - launched = generate_site._launcher_refs("batocera", config)["scph1001.bin"] + launched = generate_site._launcher_refs(config)["scph1001.bin"] text = generate_site._category_evidence_md(evidence, launched) self.assertNotIn("(by launcher)", text) self.assertIn("https://github.com/batocera-linux/batocera.linux/blob/batocera-43.1/" "package/batocera/core/batocera-configgen/", text) self.assertIn("duckstationGenerator.py:115-136", text) + def test_every_platform_links_its_launchers(self): + """Only Batocera and RetroBat were linked: Recalbox, ROCKNIX, EmuDeck, + RetroPie and RetroDECK read their launchers in the list's repository + too, and their citations came out as plain code.""" + checked = 0 + for path in sorted(Path(PLATFORMS).glob("*.yml")): + if not path.stem[0].isalpha(): + continue + config = load_platform_config(path.stem, PLATFORMS) + if not config.get("launchers"): + continue + with self.subTest(platform=path.stem): + rendered = [text for texts in generate_site._launcher_refs(config).values() + for text in texts] + self.assertTrue(rendered) + self.assertFalse([t for t in rendered if " at `" in t]) + checked += 1 + self.assertGreaterEqual(checked, 7) + def test_a_launcher_in_another_repository_is_not_linked(self): source = list_source("https://gitlab.com/recalbox/recalbox/-/raw/10.1.1/x/es_bios.xml") self.assertEqual(launcher_ref_markdown(None, "a/b.py:3"), "`b.py:3`") diff --git a/wiki/adding-a-platform.md b/wiki/adding-a-platform.md index 40082ff6e..39a61435c 100644 --- a/wiki/adding-a-platform.md +++ b/wiki/adding-a-platform.md @@ -423,7 +423,7 @@ launchers: | `fails_scope` | `emulator` when the failure needs every record of the emulator to come up empty | | `depends_on_option` | Options or conditions that decide whether the record applies | | `device` | Devices whose shipped config the record reads, set only where a package ships configs that differ between devices | -| `source_ref` | `path:lines` at the revision `source` pins | +| `source_ref` | `path:lines` in the repository and at the revision `source` pins, which the site links | Batocera's generators are read with `ast`, RetroBat's C# generators as text. ROCKNIX and EmuDeck launch from shell scripts and configs shipped with each