diff --git a/scripts/sitegen/emulatorcards.py b/scripts/sitegen/emulatorcards.py index 4ad1a8672..84ade3601 100644 --- a/scripts/sitegen/emulatorcards.py +++ b/scripts/sitegen/emulatorcards.py @@ -1092,4 +1092,4 @@ def _unsourceable_line(f: dict) -> str: wanted, and "Not collectable" sent readers away from KANJI2.ROM, which MAME's fm7740sx.zip carries.""" return (f"Not collected yet: {escape_tags(str(f['unsourceable']))} " - "([files not collected yet](../gaps.md#not-collected-yet))") + "([files not collected yet](../gaps-not-collected.md))") diff --git a/scripts/sitegen/gaps.py b/scripts/sitegen/gaps.py index 15add3f13..f1b5acabf 100644 --- a/scripts/sitegen/gaps.py +++ b/scripts/sitegen/gaps.py @@ -363,6 +363,10 @@ UPLOAD_URL = f"{sitewanted.UPLOAD_ROOT}bios" # Rows of Files to source on one page: 601 on one page made a phone page # 274,509 px long. FILES_TO_SOURCE_PART = 100 +# The two other long tables, each on a page of its own. Emulator cards link +# the second. +PER_EMULATOR_STEM = "gaps-per-emulator" +NOT_COLLECTED_STEM = "gaps-not-collected" def reading_platforms(emu_name: str, profile: dict, name: str, @@ -705,8 +709,21 @@ def _complement_rows(emulator_gaps: list[tuple[str, dict]]) -> list[str]: return rows +def _moved_table(stem: str, title: str, intro: str, head: list[str], rows: list[str], noun: str, + moved: dict[str, str] | None) -> list[str]: + """A table on the gaps page, or on a page of its own with a line here. + Two tables of 340 and 283 rows held most of the gaps page's 8,300 + elements: their first layout was a 200 ms task on a phone.""" + if moved is None: + return [*head, *rows, ""] + where = list_pages(stem, title, intro, head, [rows], moved, budget=1, + parent=("What the packs do not hold", "/gaps/")) + return [f"{count_text(len(rows), noun)}, listed on {where}.", ""] + + def _complement_intro(src_totals: dict[str, int], total_undeclared: int, - emulator_gaps: list[tuple[str, dict]]) -> list[str]: + emulator_gaps: list[tuple[str, dict]], + moved: dict[str, str] | None = None) -> list[str]: """Section 3 up to its per-emulator table: what the emulators load that no platform lists, and where those files come from.""" total_available = ( @@ -746,14 +763,19 @@ def _complement_intro(src_totals: dict[str, int], total_undeclared: int, "", "### Per emulator", "", - "| Emulator | Undeclared | bios | data | release | Bundled | Missing |", - "|----------|----------:|-----:|-----:|--------:|--------:|--------:|", - *_complement_rows(emulator_gaps), - "", + *_moved_table( + PER_EMULATOR_STEM, "Files emulators load, per emulator", + f"For each of {count_text(len(emulator_gaps), 'emulator')}, the files it loads " + "that no platform lists, counted by where they come from. Part of " + "[What the packs do not hold](gaps.md#per-emulator).", + ["| Emulator | Undeclared | bios | data | release | Bundled | Missing |", + "|----------|----------:|-----:|-----:|--------:|--------:|--------:|"], + _complement_rows(emulator_gaps), "emulator", moved), ] -def _not_collected_section(report_all: dict, profiles: dict, catalogued: dict | None) -> list[str]: +def _not_collected_section(report_all: dict, profiles: dict, catalogued: dict | None, + moved: dict[str, str] | None = None) -> list[str]: """Section 4: files the collection does not hold yet (unsourceable).""" all_unsourceable: list[dict] = [ { @@ -779,17 +801,23 @@ def _not_collected_section(report_all: dict, profiles: dict, catalogued: dict | "with the same name is never served in their place. Each is still " "wanted, and the last column names a catalog or romset that lists it.", "", - "| File | Emulator | Reason | Source ref | Listed in |", - "|------|----------|--------|-----------|-----------|", ] + rows = [] for u in sorted(all_unsourceable, key=lambda x: x["name"]): where = listed.get((u["emu_key"], str(u["name"]).casefold()), []) - lines.append( + rows.append( f"| `{u['name']}` | {u['emulator']} | {_reason_cell(u['reason'])} " f"| {source_ref_markdown(profiles[u['emu_key']], u['source_ref'])} " f"| {', '.join(where) or '-'} |" ) - lines.append("") + lines.extend(_moved_table( + NOT_COLLECTED_STEM, "Files not collected yet", + f"{count_text(len(rows), 'file')} the collection does not hold, each with the " + "emulator that loads it, why it is not collected and the catalog or romset " + "that lists it. Part of [What the packs do not hold](gaps.md#not-collected-yet).", + ["| File | Emulator | Reason | Source ref | Listed in |", + "|------|----------|--------|-----------|-----------|"], + rows, "file", moved)) return lines @@ -947,7 +975,8 @@ def generate_gap_analysis( src_totals, total_undeclared, emulator_gaps = _undeclared_gaps(report_all) if total_undeclared > 0: - lines.extend(_complement_intro(src_totals, total_undeclared, emulator_gaps)) + lines.extend(_complement_intro(src_totals, total_undeclared, emulator_gaps, + listing.moved)) # List truly missing files with platform impact emu_to_platforms = _emulator_platforms(profiles, coverages) missing = _missing_files(emulator_gaps) @@ -962,7 +991,7 @@ def generate_gap_analysis( lines.extend(_source_table(counted, rows, listing.moved)) lines.extend(_bundled_note(missing.bundled)) - lines.extend(_not_collected_section(report_all, profiles, catalogued)) + lines.extend(_not_collected_section(report_all, profiles, catalogued, listing.moved)) lines.extend(["", date_line()]) return "\n".join(lines) + "\n" diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index cf1ad4eb7..63b38ad18 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -5561,7 +5561,7 @@ class UnsourceableCardSaysWhy(unittest.TestCase): entry, {"files": [entry]}, None, [entry], lambda f: False, "file-x", )) self.assertIn("Not collected yet: written by the firmware editor", text) - self.assertIn("../gaps.md#not-collected-yet", text) + self.assertIn("../gaps-not-collected.md", text) self.assertNotIn("collectable", text) def test_the_gaps_page_names_where_a_wanted_file_is_listed(self): diff --git a/tests/test_site_reference.py b/tests/test_site_reference.py index 1770e9cfb..3507ebb40 100644 --- a/tests/test_site_reference.py +++ b/tests/test_site_reference.py @@ -1287,6 +1287,47 @@ class FilesToSourceOnAPhone(unittest.TestCase): self.assertEqual(placer.folder({"name": "x.bin"}), "") +class LongGapTablesOnPagesOfTheirOwn(unittest.TestCase): + """Mobile Lighthouse Performance stayed at 99 on /gaps/: two tables of + 340 and 283 rows were 8,300 elements, laid out in one 200 ms task. + Each moved to a page of its own, its heading and anchor kept on the + gaps page with the row count.""" + + def _page(self, moved: dict[str, str] | None) -> str: + unsourced = {"name": "KANJI2.ROM", "reason": "no dump distributed", "source_ref": ""} + gap = {"name": "a.bin", "path": "a.bin", "required": True, "source": "missing", + "in_repo": False, "identity": "", "source_ref": ""} + report = {"xm7": {"emulator": "XM7", "gaps": 1, "gap_missing": 1, "gap_bios": 0, + "gap_data": 0, "gap_large_file": 0, "gap_bundled": 0, + "unsourceable": [unsourced], "gap_details": [gap]}} + return gaps.generate_gap_analysis( + {"xm7": {"emulator": "XM7", "files": []}}, {}, {"files": {}, "indexes": {}}, + gap_report=report, listing=gaps.SourceListing(moved=moved)) + + def test_both_tables_leave_with_their_anchors_kept(self): + moved: dict[str, str] = {} + page = self._page(moved) + self.assertEqual(set(moved) - {"gaps-files-to-source"}, + {gaps.PER_EMULATOR_STEM, gaps.NOT_COLLECTED_STEM}) + self.assertNotIn("| Emulator | Undeclared |", page) + self.assertNotIn("| File | Emulator | Reason |", page) + self.assertIn("### Per emulator", page) + self.assertIn("1 emulator, listed on [a page of their own](gaps-per-emulator.md).", page) + self.assertIn('', page) + self.assertIn("## Not collected yet", page) + self.assertIn("[a page of their own](gaps-not-collected.md)", page) + own = moved[gaps.NOT_COLLECTED_STEM] + self.assertIn('link: "/gaps/"', own) + self.assertIn("| `KANJI2.ROM` | XM7 |", own) + self.assertIn("gaps.md#not-collected-yet", own) + self.assertIn("| [XM7](emulators/xm7.md) | 1 |", moved[gaps.PER_EMULATOR_STEM]) + + def test_without_pages_the_tables_stay(self): + page = self._page(None) + self.assertIn("| Emulator | Undeclared |", page) + self.assertIn("| `KANJI2.ROM` | XM7 |", page) + + GENERATED = REPO_ROOT / "website" / "src" / "generated" SCHEMA = json.loads((REPO_ROOT / "schemas" / "install-manifest.schema.json").read_text()) diff --git a/website/src/data/published-parts.json b/website/src/data/published-parts.json index e18cca25b..bd66db8bb 100644 --- a/website/src/data/published-parts.json +++ b/website/src/data/published-parts.json @@ -62,6 +62,8 @@ "gaps-files-to-source-8.md": "gaps.md", "gaps-files-to-source-9.md": "gaps.md", "gaps-files-to-source.md": "gaps.md", + "gaps-not-collected.md": "gaps.md", + "gaps-per-emulator.md": "gaps.md", "get/amberelec.md": "platforms/amberelec.md", "get/batocera.md": "platforms/batocera.md", "get/bizhawk.md": "platforms/bizhawk.md",