feat: give every Sony console its own page

A section shares its page's search fields, and "playstation 3 bios" found the PlayStation page before the Sony page that held the PS3. CONSOLE_PAGES splits Sony by console whatever the size. The search gate now expects the PlayStation 3 page in the top two for that query, the order of words being something Pagefind does not weigh, and the page first for "ps3 bios".
This commit is contained in:
Abdessamad Derraz committed 2026-11-04 03:55:07 +01:00
1 parent d8f8e865dc
commit 531edaa1ad
3 files changed
+34 -6

No files matched your search

+7 -2
View File
@@ -6107,6 +6107,11 @@ def system_install_choices(coverages: dict) -> dict[str, dict[str, list[tuple[st
# stays under 600 KB from 300 KB. game-engines was one 10.5 MB page that
# took 21 s of main-thread work on a phone.
SYSTEM_PAGE_BUDGET = 300_000
# Manufacturers whose every console gets a page of its own, whatever its
# size. A section shares its page's search fields with its neighbours, and
# a digit is on too many pages to weigh: "playstation 3 bios" found the
# PlayStation page before the Sony page that held the PlayStation 3.
CONSOLE_PAGES = frozenset({"Sony"})
# What the sections kept on a manufacturer's summary may weigh once
# rendered, estimated from their Markdown. Fitted on the Nintendo, Sega and
# Commodore summaries: highlighted install commands grow about eleven times
@@ -7281,7 +7286,7 @@ def system_pages(
boxes = {console: _install_box_weight(install_block(console)) for console in consoles}
rendered = {console: CARD_HTML_RATIO * weights[console] + INSTALL_HTML_RATIO * boxes[console]
for console in weights}
if (not boards and len(measured_text) <= budget
if (not boards and manufacturer not in CONSOLE_PAGES and len(measured_text) <= budget
and sum(rendered.values()) <= SYSTEM_SUMMARY_HTML):
text = whole_page(all_sections()) if markup.starlight() else measured_text
return {slug: (text, consoles)}
@@ -7290,7 +7295,7 @@ def system_pages(
# to pages of their own until what stays on the manufacturer's page is
# half the budget: a section of one file keeps its place, and a reader
# does not open 91 pages to browse Other.
moved: set[str] = set(boards)
moved: set[str] = set(boards) | (set(consoles) if manufacturer in CONSOLE_PAGES else set())
for console in sorted(weights, key=lambda c: (-weights[c], c)):
if sum(w for c, w in weights.items() if c not in moved) <= budget // 2:
break
+18
View File
@@ -404,5 +404,23 @@ class SearchConsoleOwnership(unittest.TestCase):
(DIST / "index.html").read_text(encoding="utf-8"))
class EverySonyConsoleHasItsPage(unittest.TestCase):
"""A section shares its page's search fields: "playstation 3 bios"
found the PlayStation page before the Sony page holding the PS3."""
def test_sony_is_split_by_console(self):
source = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
self.assertIn('CONSOLE_PAGES = frozenset({"Sony"})', source)
self.assertIn("manufacturer in CONSOLE_PAGES", source)
@unittest.skipUnless((DIST / "index.html").is_file(), "site not built")
def test_each_console_page_is_built(self):
for slug in ("sony-playstation", "sony-playstation-2", "sony-playstation-3",
"sony-playstation-4", "sony-playstation-portable", "sony-playstation-vita",
"sony-pocketstation"):
with self.subTest(page=slug):
self.assertTrue((DIST / "systems" / slug / "index.html").is_file())
if __name__ == "__main__":
unittest.main()
+9 -4
View File
@@ -71,11 +71,16 @@ QUERIES: dict[str, tuple[tuple[str, ...], int]] = {
"game boy bios": (("systems/nintendo-game-boy/",), 1),
"3ds bios": (("systems/nintendo-3ds/",), 1),
# A console another one's name begins with, both ways: the longer name's
# page holds every word of the shorter query. GBA, GBC and the
# PlayStation 3 are sections of their maker's page. Saturn.emu is an
# emulator named after its console.
# page holds every word of the shorter query. GBA and GBC are sections
# of their maker's page. Saturn.emu is an emulator named after its
# console.
"playstation 2 bios": (("systems/sony-playstation-2/",), 1),
"playstation 3 bios": (("systems/sony/",), 1),
# Every Sony console has a page of its own (CONSOLE_PAGES). The search
# weighs words, not their order, and "3" is on too many pages to weigh:
# the PlayStation page, which names BIOS v3.0 and leads "playstation
# bios", stays just above. "ps3 bios" finds the page first.
"playstation 3 bios": (("systems/sony-playstation-3/",), 2),
"ps3 bios": (("systems/sony-playstation-3/",), 1),
"game boy advance bios": (("systems/nintendo/",), 1),
"game boy color bios": (("systems/nintendo/",), 1),
"nintendo ds bios": (("systems/nintendo-nintendo-ds/",), 1),