Files
libretro/scripts/sitegen/pageregistry.py
T
Abdessamad Derraz 6e8ef2650f refactor: carry the site's page state on the run
Eleven module globals in descriptions, decorate, emulatorpage and
emulatorcards held what one build records about its pages, filled by
build.py and as a side effect of two renderers. They now live on a
PageRegistry the run carries and passes to the renderers and to
decorate_markdown_pages. get/ pages return their date (get_page_data)
instead of writing it, and a card reads the data directory members
from its CardSources. A second build in one process no longer inherits
the first one's maps, and tests build the input instead of patching
globals.
2026-11-23 23:07:32 +01:00

40 lines
2.1 KiB
Python

"""What one site build records about its pages, for the renderers and the decorator that read it."""
from __future__ import annotations
from dataclasses import dataclass, field
@dataclass
class PageRegistry:
"""The maps a build fills as it writes pages, read by later pages and by
the decorator. Keys are page paths relative to docs/ unless said."""
# Structured data a page generator knows beyond its text.
page_data: dict[str, dict] = field(default_factory=dict)
# Emulator pages whose every file comes with the app: no "BIOS files" in
# their title, and their description says so (DaedalusX64, ZEsarUX).
nothing_to_fetch: set[str] = field(default_factory=set)
# The first system, the file names, the count of required names and the
# word for them ("BIOS" or "files") of each emulator page, for its snippet.
emulator_snippets: dict[str, tuple[str, list[str], int, str]] = field(default_factory=dict)
# The noun of the title of an emulator or system page (title_noun):
# "BIOS files" when absent.
title_nouns: dict[str, str] = field(default_factory=dict)
# Pages that hold part of a page too long for one (a console of a split
# manufacturer, a run of an emulator's cards): their H1 already says
# what they are.
part_pages: set[str] = field(default_factory=set)
# Pages that answer a name after the page that owns it.
search_demoted: set[str] = field(default_factory=set)
# Data directory members by ref, then by path inside the tree.
data_members: dict[str, dict[str, dict]] = field(default_factory=dict)
# Data directory revisions by ref.
data_revisions: dict[str, dict] = field(default_factory=dict)
# The emulator pages that list each data directory, by ref.
data_readers: dict[str, list[tuple[str, str]]] = field(default_factory=dict)
# Emulator -> the platforms that run it, as resolve_platform_cores answers.
emulator_setups: dict[str, list[str]] = field(default_factory=dict)
# The measurement index items of each emulator, for the proof lines of its page.
measurement_items: dict[str, list[dict]] = field(default_factory=dict)