diff --git a/scripts/generate_site.py b/scripts/generate_site.py index 8d8ee799..3dd6d410 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -4038,6 +4038,24 @@ def generate_gap_analysis( +def _core_scope_note(config: dict, profiles: dict) -> str: + """" (all libretro)" when the platform resolves every libretro core. + + Read from what resolve_platform_cores returns, not from the shape of + ``cores:``: RetroPie and RetroDECK name ``retroarch`` in a list, which + pulls in every libretro core as ``all_libretro`` does, and the label + showed for RetroArch and Lakka only. + """ + every_libretro = resolve_platform_cores({"cores": "all_libretro"}, profiles) + resolved = resolve_platform_cores(config, profiles) + if not every_libretro or not every_libretro <= resolved: + return "" + others = len(resolved - every_libretro) + if not others: + return " (all libretro)" + return f" (all libretro, plus {_count(others, 'other core')})" + + def _render_xref_by_platform( coverages: dict, unique: dict ) -> list[str]: @@ -4047,7 +4065,6 @@ def _render_xref_by_platform( cov = coverages[pname] display = cov["platform"] config = cov["config"] - platform_cores = config.get("cores", []) lines.append(f'??? abstract "{display}"') lines.append("") @@ -4066,10 +4083,7 @@ def _render_xref_by_platform( if key in unique } - if platform_cores == "all_libretro": - lines.append(f" **{len(matched)} cores** (all libretro)") - else: - lines.append(f" **{len(matched)} cores**") + lines.append(f" **{len(matched)} cores**{_core_scope_note(config, unique)}") lines.append("") lines.append(" | Core | Classification | Systems | Files | Upstream |") diff --git a/tests/test_site_cores.py b/tests/test_site_cores.py index 0be1f5fe..b60fb636 100644 --- a/tests/test_site_cores.py +++ b/tests/test_site_cores.py @@ -44,5 +44,30 @@ class SiteCoreCounts(unittest.TestCase): self.assertEqual(shown[cov["platform"]], expected) +class AllLibretroLabel(unittest.TestCase): + """RetroPie and RetroDECK pull in every libretro core by naming retroarch + in a list, and the label read "(all libretro)" for RetroArch and Lakka + only, the two whose cores: is the string.""" + + PROFILES = { + "a": {"type": "libretro"}, + "b": {"type": "standalone + libretro"}, + "sa": {"type": "standalone"}, + } + + def test_a_list_naming_retroarch_is_labelled(self): + note = generate_site._core_scope_note( + {"cores": ["retroarch", "sa"]}, self.PROFILES) + self.assertEqual(note, " (all libretro, plus 1 other core)") + + def test_the_string_form_is_labelled(self): + note = generate_site._core_scope_note({"cores": "all_libretro"}, self.PROFILES) + self.assertEqual(note, " (all libretro)") + + def test_a_selection_is_not(self): + self.assertEqual( + generate_site._core_scope_note({"cores": ["a", "sa"]}, self.PROFILES), "") + + if __name__ == "__main__": unittest.main()