From c5a6a0fcc4871d0ea8572241bac81ce30d6e4994 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 28 Oct 2026 01:35:00 +0100 Subject: [PATCH] fix: fold the region runs on system pages Four cores and three games put 430 words on the PlayStation page, past its word ceiling. A system page now shows one line per core, and each game's outcome with its four records waits in a closed fold. --- scripts/sitemeasurements.py | 47 +++++++++++++++++++++++++++++-------- tests/test_region_check.py | 7 ++++-- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/scripts/sitemeasurements.py b/scripts/sitemeasurements.py index 39d9a4751..271d3139f 100644 --- a/scripts/sitemeasurements.py +++ b/scripts/sitemeasurements.py @@ -409,25 +409,52 @@ VARIANT_WORDS = {"full": "every regional BIOS", "own": "its own region's BIOS on "others": "the other regions' BIOS only", "pack": "the region's pack"} +REGION_SHORT = {"japan": "Japanese", "north-america": "US", "europe": "European"} +OUTCOME_WORDS = {True: "boots", False: "does not boot", None: "no verdict"} + + +def core_region_line(results: list[dict]) -> str: + """One core's outcome over its region games, in a sentence: each game + on its own BIOS, then on the other regions' BIOS.""" + own = {r["own_boots"] for r in results} + others = {r["others_boot"] for r in results} + if own == {True} and others == {True}: + return "Each region's game boots on its own BIOS and on the other regions' BIOS." + if own == {True} and others == {False}: + return "Each region's game boots on its own BIOS only." + parts = [f"{REGION_SHORT.get(r['region'], r['region'])} game: {OUTCOME_WORDS[r['own_boots']]} " + f"on its BIOS, {OUTCOME_WORDS[r['others_boot']]} on the others" for r in results] + return ", ".join(parts) + "." + + def region_section(results: list[dict], level: int = 3) -> list[str]: - """What the region runs showed for one system, with the records.""" + """What the region runs showed for one system: a line per core, the + games and their records in a fold.""" if not results: return [] lines = ["#" * level + " Region check", "", f"Each game ran with {VARIANT_WORDS['own']}, then with {VARIANT_WORDS['others']} " f"([method](../{METHOD_PAGE})).", ""] + by_core: dict[str, list[dict]] = {} for result in results: - links = ", ".join( - f"[{VARIANT_WORDS[label]}]({item['url']})" if item.get("url") else _plain(VARIANT_WORDS[label]) - for label, item in result["variants"].items()) - read = (f" It reads {', '.join(_code(name) for name in result['selected'])} " - f"when every regional BIOS is there ({_plain(result['claim'])} against the profile)." - if result["selected"] else "") + by_core.setdefault(result["core"], []).append(result) + for core, items in by_core.items(): + lines.append(f"- **{_plain(core)}**: {_plain(core_region_line(items))}") + lines.append("") + rows = [] + for result in results: + links = ", ".join(_link(item.get("url"), _cell(VARIANT_WORDS[label])) + for label, item in result["variants"].items()) + names = ", ".join(f"{_cell(name)}" for name in result["selected"]) + read = (f" It reads {names} with every regional BIOS there " + f"({_cell(result['claim'])} against the profile)." if result["selected"] else "") basis = ("" if result["judged_by"] == "verdict" else " Judged against the run with every regional BIOS until reference frames are recorded.") - lines.append(f"- **{_plain(result['core'])}**, {_plain(result['game'])}: " - f"{_plain(result['sentence'])}{read}{basis} Records: {links}.") - lines.append("") + rows.append(f"
  • {_cell(result['core'])}, {_cell(result['game'])}: " + f"{_cell(result['sentence'])}{read}{basis} Records: {links}.
  • ") + # One line: MDX reads an HTML block split over lines as paragraphs. + lines += ['
    Each game and its records
    ", ""] return lines diff --git a/tests/test_region_check.py b/tests/test_region_check.py index 176428fc6..f39cf5aee 100644 --- a/tests/test_region_check.py +++ b/tests/test_region_check.py @@ -225,8 +225,11 @@ class SitePages(unittest.TestCase): for label, item in result["variants"].items(): item["url"] = f"https://example.org/{label}" text = "\n".join(sm.region_section([result])) - self.assertIn("The Japanese BIOS boots the Japanese game, the other regions' BIOS do not.", text) - self.assertIn("[its own region's BIOS only](https://example.org/own)", text) + self.assertIn("- **mednafen_psx**: Each region's game boots on its own BIOS only.", text) + self.assertIn("The Japanese BIOS boots the Japanese game, the other regions' BIOS do not.", text) + # The per-game lines and their records wait in a closed fold. + self.assertIn('
    ', text) + self.assertIn('its own region's BIOS only', text) self.assertIn("scph5500.bin", text) self.assertNotIn("reference frames are recorded", text) self.assertEqual(sm.region_section([]), [])