fix: place system pages by the reviewed sections

The site placed a system page through an index of folders only, while
own_section reads the folders plus the reviewed parents. The Atom has no
folder of its own and was placed on the BBC Micro section while every link
named its Atom section. Both now build their index from section_pairs_of,
and a test checks every id against own_section on the repository data.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 10:30:59 +01:00
1 parent 15f913d0ba
commit b8fe881327
3 files changed
+71 -12

No files matched your search

+20 -10
View File
@@ -40,6 +40,25 @@ def program_names(profiles: dict[str, dict]) -> set[str]:
return names
def section_pairs_of(sections: dict[str, dict] | set[tuple[str, str]]) -> set[tuple[str, str]]:
"""Every (manufacturer, console) section the system pages carry.
``sections`` maps each manufacturer to its consoles or is a set of
pairs. A reviewed parent under a maker the pages carry is a section even
with no folder of its own: the Atom's sets sit under bios/Arcade, and
the system pages file them under Acorn
(sitegen.systempages.arcade_board_sections).
"""
pairs = (
{(mfr, console) for mfr, consoles in sections.items() for console in consoles}
if isinstance(sections, dict) else set(sections)
)
makers = {mfr for mfr, _console in pairs}
pairs |= {parent for parent in SYSTEM_PARENTS.values()
if parent[0] in makers and parent[0] not in PROGRAM_TOPS}
return pairs
def set_console_sections(
sections: dict[str, dict] | set[tuple[str, str]],
programs: set[str] | frozenset[str] = frozenset(),
@@ -50,16 +69,7 @@ def set_console_sections(
group them, or is a set of (manufacturer, console) pairs. ``programs``
are the emulator names, which never name a system.
"""
pairs = (
{(mfr, console) for mfr, consoles in sections.items() for console in consoles}
if isinstance(sections, dict) else set(sections)
)
# A reviewed parent under a maker the pages carry is a section even with
# no folder of its own: the Atom's sets sit under bios/Arcade, and the
# system pages file them under Acorn (sitegen.systempages.arcade_board_sections).
makers = {mfr for mfr, _console in pairs}
pairs |= {parent for parent in SYSTEM_PARENTS.values()
if parent[0] in makers and parent[0] not in PROGRAM_TOPS}
pairs = section_pairs_of(sections)
from core.anchors import unique_anchor, toc_slug
_console_sections.clear()
+2 -2
View File
@@ -5,7 +5,7 @@ from __future__ import annotations
from dataclasses import dataclass
from model.collection import copy_places, manufacturer_slug
from model.systemnames import console_index, spelled_section
from model.systemnames import console_index, section_pairs_of, spelled_section
from resolve.localfile import resolution_is_hash_exact, resolve_local_file
from resolve.ownership import BUCKET_FOLDERS, names_manufacturer
@@ -179,7 +179,7 @@ def system_pages_from_data(
# Map system_id -> (manufacturer, console) via platform file entries
index = _FolderIndex(
db, name_consoles,
console_index((mfr, console) for mfr, consoles in manufacturers.items() for console in consoles),
console_index(section_pairs_of(manufacturers)),
_copies_by_path(db),
)
pages: dict[str, tuple[str, str]] = {}
+49
View File
@@ -286,6 +286,55 @@ class SystemEmulatorsWhenNoIdMatches(unittest.TestCase):
)
@unittest.skipUnless((REPO_ROOT / "database.json").is_file(), "database absent")
class PagesFollowOwnSection(unittest.TestCase):
"""The site places a system page by the section own_section names.
The two kept their own index: Atari and Camputers both file a Lynx, and
the Atom, a reviewed parent with no folder of its own, was placed on
the BBC Micro section while every link named its Atom section.
"""
@classmethod
def setUpClass(cls):
from model.database import load_database
from model.platforms import load_platform_config
from model.profiles import load_emulator_profiles
from model.registry import list_registered_platforms
db = load_database(str(REPO_ROOT / "database.json"))
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"), skip_aliases=False)
manufacturers = collection.group_by_manufacturer(db)
systemnames.set_console_sections(manufacturers, systemnames.program_names(profiles))
platforms = REPO_ROOT / "platforms"
coverages = {
name: {"config": load_platform_config(name, str(platforms))}
for name in list_registered_platforms(str(platforms))
}
cls.pages = places.system_pages_from_data(manufacturers, coverages, db, profiles)
ids = {str(sid) for profile in profiles.values() for sid in profile.get("systems") or []}
for coverage in coverages.values():
ids |= {str(sid) for sid in coverage["config"].get("systems") or {}}
cls.ids = sorted(ids | set(cls.pages))
def test_every_own_section_is_the_page(self):
for sys_id in self.ids:
own = systemnames.own_section(sys_id)
if own is None:
continue
with self.subTest(system=sys_id):
self.assertEqual(
self.pages.get(sys_id), (collection.manufacturer_slug(own[0]), own[1]))
def test_named_cases(self):
self.assertEqual(self.pages.get("atari-lynx"), ("atari", "Lynx"))
self.assertEqual(self.pages.get("atom"), ("acorn", "Atom"))
# A program's folder places its page, though it is no system's own.
self.assertIsNone(systemnames.own_section("scummvm"))
self.assertEqual(self.pages.get("scummvm"), ("scummvm", "ScummVM"))
self.assertEqual(self.pages.get("solarus"), ("game-engines", "Solarus"))
DOCS = REPO_ROOT / "website" / "src" / "content" / "docs"