From dedbde7917107ebad8c92415cfbc36b157c223f1 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Mon, 23 Nov 2026 22:38:15 +0100 Subject: [PATCH] fix: pack readme reads the guides of its run model.guides took its platforms folder from the site's inputs, so a pack built with --platforms-dir printed the manual and install commands of the repository's guides. The loaders now take the folder (or the install address) explicitly; sitegen.guidedata binds them to the site's inputs, the pack README to the run's platforms folder, the release notes and the site validation to the folder they were given. --- .github/workflows/deploy-site.yml | 1 + scripts/model/guides.py | 92 ++++++++++--------------------- scripts/packs/platformpack.py | 1 + scripts/packs/readme.py | 52 +++++++++++------ scripts/release/notes.py | 7 ++- scripts/sitegen/agents.py | 3 +- scripts/sitegen/build.py | 2 +- scripts/sitegen/consolecards.py | 2 +- scripts/sitegen/diagrams.py | 2 +- scripts/sitegen/getpages.py | 2 +- scripts/sitegen/guidedata.py | 73 ++++++++++++++++++++++++ scripts/sitegen/guidepage.py | 3 +- scripts/sitegen/guides.py | 3 +- scripts/sitegen/home.py | 3 +- scripts/sitegen/imagefetch.py | 2 +- scripts/sitegen/install.py | 2 +- scripts/sitegen/nav.py | 2 +- scripts/sitegen/pageprep.py | 4 +- scripts/sitegen/platformindex.py | 2 +- scripts/sitegen/platformpage.py | 2 +- scripts/sitegen/readme.py | 3 +- scripts/sitegen/validate.py | 4 +- scripts/sitegen/whichpack.py | 5 +- tests/test_audit_regressions.py | 6 +- tests/test_doc_pages.py | 6 +- tests/test_extract_targets.py | 2 +- tests/test_pack_readme.py | 2 +- tests/test_release_packs.py | 4 +- tests/test_site_agents.py | 4 +- tests/test_site_bootstrap.py | 2 +- tests/test_site_content_data.py | 33 +++++++++-- tests/test_site_demo.py | 2 +- tests/test_site_emulators.py | 4 +- tests/test_site_entry.py | 71 ++++++++++++------------ tests/test_site_funnel.py | 4 +- tests/test_site_handheld.py | 4 +- tests/test_site_integration.py | 2 +- tests/test_site_nav.py | 4 +- tests/test_site_page_text.py | 2 +- tests/test_site_steps.py | 2 +- tests/test_site_wiki.py | 2 +- 41 files changed, 258 insertions(+), 170 deletions(-) create mode 100644 scripts/sitegen/guidedata.py diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml index 10adefdf3..d39bff899 100644 --- a/.github/workflows/deploy-site.yml +++ b/.github/workflows/deploy-site.yml @@ -167,6 +167,7 @@ on: - "scripts/sitegen/fields.py" - "scripts/sitegen/gaps.py" - "scripts/sitegen/getpages.py" + - "scripts/sitegen/guidedata.py" - "scripts/sitegen/guidepage.py" - "scripts/sitegen/guides.py" - "scripts/sitegen/handheld.py" diff --git a/scripts/model/guides.py b/scripts/model/guides.py index 7d22a9ce7..f1877d773 100644 --- a/scripts/model/guides.py +++ b/scripts/model/guides.py @@ -3,12 +3,12 @@ from __future__ import annotations import functools +import os import re import textwrap from dataclasses import dataclass, fields from pathlib import Path -from model import siteinputs from model.registry import load_platform_registry from model.sources import source_yaml @@ -409,101 +409,67 @@ def _guides_in(platforms: Path) -> dict: return load_guides(platforms / GUIDES_NAME) -def loaded() -> dict: - """The guides of the platforms folder the run describes, read on first use.""" - return _guides_in(siteinputs.current().platforms) +def loaded(platforms: str | os.PathLike[str]) -> dict: + """The guides of a platforms folder, read once per folder.""" + return _guides_in(Path(platforms)) -def platform_guides() -> dict[str, Guide]: - return loaded()["guides"] +def install_base(platforms: str | os.PathLike[str]) -> str: + return loaded(platforms)["install_base"] -def install_base() -> str: - return loaded()["install_base"] +def install_sh(base: str) -> str: + """The sh bootstrap the site at *base* serves (sitegen/bootstrap.py writes it).""" + return f"{base}/{SH_NAME}" -def install_sh() -> str: - """The sh bootstrap the site serves (sitegen/bootstrap.py writes it).""" - return f"{install_base()}/{SH_NAME}" +def install_ps1(base: str) -> str: + """The PowerShell bootstrap the site at *base* serves.""" + return f"{base}/{PS1_NAME}" -def install_ps1() -> str: - """The PowerShell bootstrap the site serves.""" - return f"{install_base()}/{PS1_NAME}" - - -def device_groups() -> dict[str, tuple[str, str]]: - return loaded()["device_groups"] - - -def group_anchors() -> dict[str, str]: - return loaded()["group_anchors"] - - -def also_runs() -> dict[str, tuple[tuple[str, str, str, str, str], ...]]: - return loaded()["also_runs"] - - -def group_tiles() -> dict[str, tuple[Tile, ...]]: - return loaded()["tiles"] - - -def handheld_guide() -> HandheldGuide | None: - return loaded()["handheld_guide"] - - -def terminals() -> dict[str, tuple[str, str, str]]: - return loaded()["terminals"] - - -def trust_items() -> tuple[str, ...]: - return loaded()["trust_items"] - - -def folder_list(name: str, registry: dict | None = None) -> list[tuple[str, str]]: +def folder_list(name: str, platforms: str | os.PathLike[str], + registry: dict | None = None) -> list[tuple[str, str]]: """Every folder a guide names, as (where, path): the common ones, the rarer builds, and the systems the registry detects when the guide says so.""" - guide = platform_guides()[name] + data = loaded(platforms) + guide = data["guides"][name] rows = [*guide.folders, *guide.more_folders] if guide.more_folders_detected: rows += [(system, f"`{folder}`") - for system, folder in detected_systems(registry or loaded()["registry"], name)] + for system, folder in detected_systems(registry or data["registry"], name)] return rows -def _plain_folders(name: str) -> str: - rows = folder_list(name) +def _plain_folders(name: str, platforms: str | os.PathLike[str]) -> str: + rows = folder_list(name, platforms) width = max(len(where) for where, _path in rows) + 1 return "\n".join(f"{where + ':':<{width}} {path.replace('`', '')}" for where, path in rows) -def setup_count() -> int: - """Setups the site covers: every registered platform, since each keeps - its page, its pack and its command. The one count every page states.""" - return len(platform_guides()) - - -def pack_manual(name: str) -> str: +def pack_manual(name: str, platforms: str | os.PathLike[str]) -> str: """The manual part of a pack README, indented as the README is, or empty.""" - guide = platform_guides().get(name) + guide = loaded(platforms)["guides"].get(name) if not guide or not guide.pack_manual: return "" text = guide.pack_manual.rstrip("\n") if "{folders}" in text: indent = next(line[: len(line) - len(line.lstrip())] for line in text.splitlines() if "{folders}" in line) - text = text.replace("{folders}", textwrap.indent(_plain_folders(name), indent).lstrip()) + text = text.replace("{folders}", + textwrap.indent(_plain_folders(name, platforms), indent).lstrip()) return textwrap.indent(text, " ") + "\n\n" -def install_command(shell: str, args: str = "") -> str: - """The one-liner for a shell, with installer options when given. +def install_command(shell: str, args: str = "", *, base: str) -> str: + """The one-liner for a shell, with installer options when given, from + the site at *base*. PowerShell passes options only through a scriptblock: `irm ... | iex` takes none. """ if shell == "sh": - return f"curl -fsSL {install_sh()} | sh" + (f" -s -- {args}" if args else "") + return f"curl -fsSL {install_sh(base)} | sh" + (f" -s -- {args}" if args else "") if args: - return f"&([scriptblock]::Create((irm {install_ps1()}))) {args}" - return f"irm {install_ps1()} | iex" + return f"&([scriptblock]::Create((irm {install_ps1(base)}))) {args}" + return f"irm {install_ps1(base)} | iex" diff --git a/scripts/packs/platformpack.py b/scripts/packs/platformpack.py index 011abc332..3158451e8 100644 --- a/scripts/packs/platformpack.py +++ b/scripts/packs/platformpack.py @@ -974,6 +974,7 @@ class _PlatformPackBuild: readme_text = build_readme( plan.platform_name, plan.platform_display, plan.base_dest, self.total_files, len(plan.pack_systems), + platforms_dir=plan.platforms_dir, source=opts.source, contributors=registry.get("contributed_by", []), regions=opts.regions, diff --git a/scripts/packs/readme.py b/scripts/packs/readme.py index d83dada64..18f404ae6 100644 --- a/scripts/packs/readme.py +++ b/scripts/packs/readme.py @@ -5,11 +5,14 @@ goes, and which ones the user has to rename.""" from __future__ import annotations +import os +from pathlib import Path from typing import TYPE_CHECKING, TypedDict from core.options import reject_unknown +from core.paths import PLATFORMS_DIR, REPO_ROOT from model.region import label as region_label -from model.guides import install_command, pack_manual +from model.guides import GUIDES_NAME, install_base, install_command, pack_manual if TYPE_CHECKING: from typing_extensions import Unpack @@ -24,7 +27,16 @@ def _detect_systems(detect: list[dict]) -> list[str]: return [name for name in order if name in seen] -def _from_pack(platform_name: str, posix: bool, windows: bool, +def _guides_dir(platforms_dir: str | os.PathLike[str]) -> Path: + """The folder whose guides describe a pack: the run's own platforms + folder, or the repository's when that folder holds no guides file (a + test tree, a partial copy), the one other place the install address is + written.""" + folder = Path(platforms_dir) + return folder if (folder / GUIDES_NAME).is_file() else REPO_ROOT / PLATFORMS_DIR + + +def _from_pack(platform_name: str, posix: bool, windows: bool, base: str, dest: tuple[str, str] = ("", "")) -> list[str]: """The same command, reading the files from the ZIP in hand. The one-liner alone downloads every file again.""" @@ -32,14 +44,14 @@ def _from_pack(platform_name: str, posix: bool, windows: bool, lines = [" Already have this ZIP? Add --from-pack and its path: the files", " come from it, not from the network. For a pack in parts, name one part.", ""] if posix: - lines.append(f" {install_command('sh', f'{args} /path/to/pack.zip{dest[0]}')}") + lines.append(f" {install_command('sh', f'{args} /path/to/pack.zip{dest[0]}', base=base)}") if windows: pack = f"{args} C:\\path\\to\\pack.zip{dest[1]}" - lines.append(f" {install_command('powershell', pack)}") + lines.append(f" {install_command('powershell', pack, base=base)}") return [*lines, ""] -def _card_section(platform_name: str, display: str) -> str: +def _card_section(platform_name: str, display: str, base: str) -> str: """The one-line install for a frontend whose files live on its SD card. The installer runs on the computer the card is mounted on, and the card @@ -51,12 +63,13 @@ def _card_section(platform_name: str, display: str) -> str: " ---------------------------------\n" " With the SD card mounted on a computer, name its root with --dest.\n" " Linux and macOS: run this in a terminal:\n\n" - f" {install_command('sh', f'--platform {platform_name} --dest /path/to/card')}\n\n" + f" {install_command('sh', f'--platform {platform_name} --dest /path/to/card', base=base)}\n\n" " Windows: run this in PowerShell (E: being the card):\n\n" - f" {install_command('powershell', card_ps1)}\n\n" + f" {install_command('powershell', card_ps1, base=base)}\n\n" f" The installer writes each file where {display} hands it to the core\n" " and checks every file.\n\n" - + "\n".join(_from_pack(platform_name, True, True, (" --dest /path/to/card", " --dest E:\\"))) + + "\n".join(_from_pack(platform_name, True, True, base, + (" --dest /path/to/card", " --dest E:\\"))) + "\n" ) @@ -79,6 +92,7 @@ def _card_manual(display: str) -> str: def _automatic_section( platform_name: str, display: str, detect: list[dict], standalone_copies: list[dict] | None, + base: str, ) -> str: """The one-line install, for every system the registry detects the platform on. Written per platform by hand, it left ROCKNIX and MiSTer @@ -101,14 +115,15 @@ def _automatic_section( else: labels = {"linux": "Linux", "darwin": "macOS"} where = f"{' and '.join(labels[name] for name in posix)}: run this in a terminal:" - lines += [f" {where}", "", f" {install_command('sh')}", ""] + lines += [f" {where}", "", f" {install_command('sh', base=base)}", ""] if "windows" in systems: - lines += [" Windows: run this in PowerShell:", "", f" {install_command('powershell')}", ""] + lines += [" Windows: run this in PowerShell:", "", + f" {install_command('powershell', base=base)}", ""] lines += [ f" The installer finds the {display} BIOS folder on this machine and", " installs there, checking every file. --dest names another folder.", "", - *_from_pack(platform_name, bool(posix), "windows" in systems), + *_from_pack(platform_name, bool(posix), "windows" in systems, base), ] # On a desktop: an emulator folder under the home of a console's own # system is not one its frontend reads. @@ -120,9 +135,9 @@ def _automatic_section( "", ] if posix: - lines.append(f" {install_command('sh', '--standalone-copies')}") + lines.append(f" {install_command('sh', '--standalone-copies', base=base)}") if "windows" in systems: - lines.append(f" {install_command('powershell', '--standalone-copies')}") + lines.append(f" {install_command('powershell', '--standalone-copies', base=base)}") lines.append("") return "\n".join(lines) + "\n" @@ -213,6 +228,7 @@ class ReadmeOptions(TypedDict, total=False): save_where: str save_by_system: bool case_twins: list[tuple[str, str]] | None + platforms_dir: str def build_readme( @@ -235,6 +251,8 @@ def build_readme( packed file, with the one it holds: given for a platform that also runs where names keep their case (EmuDeck and RetroArch on Linux), where the core asking for the other spelling finds nothing. + ``platforms_dir`` is the run's platforms folder, whose guides give the + manual and the install address (the repository's when not given). """ reject_unknown("build_readme", options, ReadmeOptions.__optional_keys__) regions = options.get("regions") @@ -295,21 +313,23 @@ def _install_guide( platform_name: str, platform_display: str, base_dest: str, options: ReadmeOptions ) -> str: """The installation steps, the case twins and the save folder.""" + guides_dir = _guides_dir(options.get("platforms_dir") or REPO_ROOT / PLATFORMS_DIR) + base = install_base(guides_dir) detect = list(options.get("detect") or []) bios_paths = [str(rule.get("bios_path", "")) for rule in detect] if any(rule.get("method") == "card_marker" for rule in detect): guide = ( "INSTALLATION GUIDE\n\n" - + _card_section(platform_name, platform_display) + + _card_section(platform_name, platform_display, base) + _card_manual(platform_display) ) else: guide = ( "INSTALLATION GUIDE\n\n" + _automatic_section( - platform_name, platform_display, detect, options.get("standalone_copies") + platform_name, platform_display, detect, options.get("standalone_copies"), base ) - + (pack_manual(platform_name) or _generic_manual(bios_paths)) + + (pack_manual(platform_name, guides_dir) or _generic_manual(bios_paths)) ) case_twins = options.get("case_twins") diff --git a/scripts/release/notes.py b/scripts/release/notes.py index 52fd6f44f..fa5848a2a 100644 --- a/scripts/release/notes.py +++ b/scripts/release/notes.py @@ -8,7 +8,7 @@ from collections.abc import Callable from core.text import series from core.sizes import size_text -from model.guides import install_command +from model.guides import install_base, install_command from model.platforms import load_platform_config from model.releaserecord import pack_label, pack_owner from model.registry import ( @@ -186,6 +186,7 @@ def render(record: dict, platforms_dir: str, whats_new: str, packs = record.get("packs", {}) folders = _extract_folders(record, platforms_dir) tag = str(record.get("tag", "")) + base = install_base(platforms_dir) lines = [ "### Get the BIOS files", "", @@ -193,12 +194,12 @@ def render(record: dict, platforms_dir: str, whats_new: str, "", "**Linux, macOS, Steam Deck**", "```sh", - install_command("sh"), + install_command("sh", base=base), "```", "", "**Windows**", "```powershell", - install_command("powershell"), + install_command("powershell", base=base), "```", "", f"**On a handheld**: [get the app for the system]({SITE}{HANDHELD_PAGE}).", diff --git a/scripts/sitegen/agents.py b/scripts/sitegen/agents.py index 38053f7cb..7b1ba2267 100644 --- a/scripts/sitegen/agents.py +++ b/scripts/sitegen/agents.py @@ -19,7 +19,8 @@ import json from collections.abc import Callable from pathlib import Path -from model.guides import PACKAGE_COMMAND, install_command +from model.guides import PACKAGE_COMMAND +from sitegen.guidedata import install_command from sitegen.config import SITE_ORIGIN, SITE_URL SITE = SITE_URL diff --git a/scripts/sitegen/build.py b/scripts/sitegen/build.py index 1f4db382e..c7258a38b 100644 --- a/scripts/sitegen/build.py +++ b/scripts/sitegen/build.py @@ -19,7 +19,7 @@ from model.collection import group_by_manufacturer, manufacturer_slug from model.composition import compute_composition from model.database import load_database from model.dumpcatalog import load_provenance_snapshots -from model.guides import handheld_guide +from sitegen.guidedata import handheld_guide from model.profiles import is_emulator, lists_files, load_emulator_profiles from model.registry import list_registered_platforms, load_platform_registry from model.systemnames import program_names, set_console_sections, system_name diff --git a/scripts/sitegen/consolecards.py b/scripts/sitegen/consolecards.py index daff84aed..cfd2aa2c8 100644 --- a/scripts/sitegen/consolecards.py +++ b/scripts/sitegen/consolecards.py @@ -8,7 +8,7 @@ from typing import TypeVar from core.text import series from model.collection import profiles_on_disk from model.composition import GAME_DATA_TOPS -from model.guides import install_ps1, install_sh +from sitegen.guidedata import install_ps1, install_sh from model.profiles import entry_system_ids from packs.consumers import FileConsumers from sitegen.cards import emulator_display, romset_releases, system_file_card diff --git a/scripts/sitegen/diagrams.py b/scripts/sitegen/diagrams.py index 8c6462e64..5072f60b0 100644 --- a/scripts/sitegen/diagrams.py +++ b/scripts/sitegen/diagrams.py @@ -405,7 +405,7 @@ def _setups_in(platforms_dir: str) -> tuple[str, ...]: def setups_named(named: list[str]) -> str: """*named*, then how many other setups there are: "A, B and 15 more".""" - from model.guides import setup_count + from sitegen.guidedata import setup_count others = setup_count() - len(named) return ", ".join(named) + (f" and {others} more" if others else "") diff --git a/scripts/sitegen/getpages.py b/scripts/sitegen/getpages.py index fd08290de..191890aba 100644 --- a/scripts/sitegen/getpages.py +++ b/scripts/sitegen/getpages.py @@ -7,7 +7,7 @@ import re from model import releaserecord from model import siteinputs -from model.guides import device_groups, group_tiles, platform_guides, handheld_guide +from sitegen.guidedata import device_groups, group_tiles, platform_guides, handheld_guide from model.platforms import load_platform_config from model.registry import load_platform_registry from installer_build.handhelds import GROUP_PAGE diff --git a/scripts/sitegen/guidedata.py b/scripts/sitegen/guidedata.py new file mode 100644 index 000000000..5c0fd6542 --- /dev/null +++ b/scripts/sitegen/guidedata.py @@ -0,0 +1,73 @@ +"""The guides of the platforms folder the site run describes (siteinputs).""" + +from __future__ import annotations + +from model import guides +from model import siteinputs +from model.guides import Guide, HandheldGuide, Tile + + +def loaded() -> dict: + return guides.loaded(siteinputs.current().platforms) + + +def platform_guides() -> dict[str, Guide]: + return loaded()["guides"] + + +def install_base() -> str: + return loaded()["install_base"] + + +def install_sh() -> str: + """The sh bootstrap the site serves (sitegen/bootstrap.py writes it).""" + return guides.install_sh(install_base()) + + +def install_ps1() -> str: + """The PowerShell bootstrap the site serves.""" + return guides.install_ps1(install_base()) + + +def install_command(shell: str, args: str = "") -> str: + """The one-liner for a shell, as the site prints it.""" + return guides.install_command(shell, args, base=install_base()) + + +def device_groups() -> dict[str, tuple[str, str]]: + return loaded()["device_groups"] + + +def group_anchors() -> dict[str, str]: + return loaded()["group_anchors"] + + +def also_runs() -> dict[str, tuple[tuple[str, str, str, str, str], ...]]: + return loaded()["also_runs"] + + +def group_tiles() -> dict[str, tuple[Tile, ...]]: + return loaded()["tiles"] + + +def handheld_guide() -> HandheldGuide | None: + return loaded()["handheld_guide"] + + +def terminals() -> dict[str, tuple[str, str, str]]: + return loaded()["terminals"] + + +def trust_items() -> tuple[str, ...]: + return loaded()["trust_items"] + + +def folder_list(name: str, registry: dict | None = None) -> list[tuple[str, str]]: + """Every folder a guide names (model.guides.folder_list).""" + return guides.folder_list(name, siteinputs.current().platforms, registry) + + +def setup_count() -> int: + """Setups the site covers: every registered platform, since each keeps + its page, its pack and its command. The one count every page states.""" + return len(platform_guides()) diff --git a/scripts/sitegen/guidepage.py b/scripts/sitegen/guidepage.py index 03f79140e..6af660418 100644 --- a/scripts/sitegen/guidepage.py +++ b/scripts/sitegen/guidepage.py @@ -10,13 +10,12 @@ from model import releaserecord from model import siteinputs from model.collection import profiles_on_disk from model.guides import ( - platform_guides, Guide, HandheldGuide, HandheldSystem, - terminals, detected_systems as _detected_systems, ) +from sitegen.guidedata import platform_guides, terminals from model.registry import load_platform_registry from resolve.nativemode import digest_algorithm from installer_build.handhelds import GROUP_PAGE diff --git a/scripts/sitegen/guides.py b/scripts/sitegen/guides.py index d97be06d0..f6f3b0c6e 100644 --- a/scripts/sitegen/guides.py +++ b/scripts/sitegen/guides.py @@ -13,7 +13,8 @@ from __future__ import annotations from sitegen import markup -from model.guides import Guide, terminals, trust_items, install_command +from model.guides import Guide +from sitegen.guidedata import terminals, trust_items, install_command # The title over each command block, by the shell it is written for. diff --git a/scripts/sitegen/home.py b/scripts/sitegen/home.py index f5ffd754f..491007a0e 100644 --- a/scripts/sitegen/home.py +++ b/scripts/sitegen/home.py @@ -7,7 +7,8 @@ import html from core.paths import PLATFORMS_DIR from core.sizes import size_text from model.composition import compute_composition -from model.guides import device_groups, group_tiles, platform_guides, Guide, trust_items, setup_count +from model.guides import Guide +from sitegen.guidedata import device_groups, group_tiles, platform_guides, trust_items, setup_count from model.profiles import unique_emulator_profiles from model.registry import load_platform_registry from sitegen import markup diff --git a/scripts/sitegen/imagefetch.py b/scripts/sitegen/imagefetch.py index 4439972c0..583ff5651 100644 --- a/scripts/sitegen/imagefetch.py +++ b/scripts/sitegen/imagefetch.py @@ -11,7 +11,7 @@ from pathlib import Path from core.paths import DB_FILE, PLATFORMS_DIR, REPO_ROOT from model.collection import group_by_manufacturer from model.database import load_database -from model.guides import group_tiles, platform_guides +from sitegen.guidedata import group_tiles, platform_guides from model.registry import load_platform_registry from scraper.base_scraper import FetchError, fetch_bytes from sitegen.imagenormalize import ( diff --git a/scripts/sitegen/install.py b/scripts/sitegen/install.py index ffdef6288..44dfd2d11 100644 --- a/scripts/sitegen/install.py +++ b/scripts/sitegen/install.py @@ -13,7 +13,7 @@ from pathlib import Path from core.text import series from model import siteinputs from model.collection import profiles_in -from model.guides import platform_guides, terminals, install_command +from sitegen.guidedata import platform_guides, terminals, install_command from model.platforms import load_platform_config from model.registry import list_release_pack_platforms from model.profiles import reads_own_files diff --git a/scripts/sitegen/nav.py b/scripts/sitegen/nav.py index 491d17843..7e555dcae 100644 --- a/scripts/sitegen/nav.py +++ b/scripts/sitegen/nav.py @@ -8,7 +8,7 @@ from pathlib import Path from model.collection import manufacturer_slug from model.composition import GAME_DATA_TOPS -from model.guides import device_groups, group_tiles, handheld_guide +from sitegen.guidedata import device_groups, group_tiles, handheld_guide from model.profiles import unique_emulator_profiles from sitegen import measurements as sitemeasurements, starlight as sitestarlight from core.paths import REPO_ROOT diff --git a/scripts/sitegen/pageprep.py b/scripts/sitegen/pageprep.py index 20201c601..8f1c7bb49 100644 --- a/scripts/sitegen/pageprep.py +++ b/scripts/sitegen/pageprep.py @@ -104,7 +104,7 @@ FENCE_TITLES = {"sh": "Terminal", "powershell": "PowerShell"} def _installer_args(body: str) -> str: """The options of a one-line install command, continuation lines joined.""" - from model.guides import install_sh + from sitegen.guidedata import install_sh line = " ".join(part.strip().rstrip("\\").strip() for part in body.splitlines()) match = re.fullmatch(rf"curl -fsSL {re.escape(install_sh())} \| sh(?: -s -- (.+))?", line) @@ -127,7 +127,7 @@ def expand_commands(markdown: str) -> str: gives a tab its own options, for a folder that differs there.""" if "os-tabs" not in markdown: return markdown - from model.guides import terminals, install_command + from sitegen.guidedata import terminals, install_command def replace(match: re.Match[str]) -> str: indent = match.group("indent") diff --git a/scripts/sitegen/platformindex.py b/scripts/sitegen/platformindex.py index 9b15d2631..cbf555bcd 100644 --- a/scripts/sitegen/platformindex.py +++ b/scripts/sitegen/platformindex.py @@ -3,7 +3,7 @@ from __future__ import annotations from model import releaserecord -from model.guides import device_groups, group_tiles, platform_guides +from sitegen.guidedata import device_groups, group_tiles, platform_guides from resolve.nativemode import check_label from sitegen import markup from sitegen.guidepage import NO_ZIP_FAQ diff --git a/scripts/sitegen/platformpage.py b/scripts/sitegen/platformpage.py index f002d7f4d..ae33db6bb 100644 --- a/scripts/sitegen/platformpage.py +++ b/scripts/sitegen/platformpage.py @@ -5,7 +5,7 @@ from __future__ import annotations import json import re -from model.guides import platform_guides +from sitegen.guidedata import platform_guides from model.systemnames import system_name from resolve.nativemode import check_label, reads_file_contents from sitegen import markup diff --git a/scripts/sitegen/readme.py b/scripts/sitegen/readme.py index 6af6e85b6..6f95ef6bc 100644 --- a/scripts/sitegen/readme.py +++ b/scripts/sitegen/readme.py @@ -19,7 +19,8 @@ from core.sizes import size_text from core import upstream from installer_build.module import installer_module from model.composition import compute_composition, count_catalog_matched -from model.guides import PACKAGE_COMMAND, install_command +from model.guides import PACKAGE_COMMAND +from sitegen.guidedata import install_command from model.largefiles import load_registered_paths from model.profiles import load_emulator_profiles, unique_emulator_profiles from model.registry import list_registered_platforms diff --git a/scripts/sitegen/validate.py b/scripts/sitegen/validate.py index 0a2100d3d..402810ead 100644 --- a/scripts/sitegen/validate.py +++ b/scripts/sitegen/validate.py @@ -419,7 +419,7 @@ def _check_get_pages( """ sys.path.insert(0, str(Path(__file__).resolve().parent)) from model import releaserecord - from model.guides import install_sh + from model.guides import install_base, install_sh from model.registry import list_registered_platforms, list_release_pack_platforms if not (platforms_dir / "_registry.yml").is_file(): @@ -444,7 +444,7 @@ def _check_get_pages( packs = [a for a in assets if "_BIOS_Pack" in a] if packs: issues.append(f"{rel}: links a pack for a setup without one: {packs[0]}") - if f"{install_sh()} | sh" not in (site / rel).read_text(encoding="utf-8"): + if f"{install_sh(install_base(platforms_dir))} | sh" not in (site / rel).read_text(encoding="utf-8"): issues.append(f"{rel}: gives no install command") return issues diff --git a/scripts/sitegen/whichpack.py b/scripts/sitegen/whichpack.py index af181d848..9ecbe368d 100644 --- a/scripts/sitegen/whichpack.py +++ b/scripts/sitegen/whichpack.py @@ -6,13 +6,12 @@ from model import releaserecord from core.sizes import size_text from core.ziptools import build_zip_contents_index from model import siteinputs -from model.guides import ( +from model.guides import Guide, PACKAGE_COMMAND +from sitegen.guidedata import ( also_runs, device_groups, group_anchors, platform_guides, - Guide, - PACKAGE_COMMAND, terminals, install_command, ) diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index a6ee0961c..ce318e5e2 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -60,7 +60,7 @@ class ReadmeRegressions(unittest.TestCase): def test_advertised_bootstrap_urls_are_the_shipped_ones(self): from sitegen import bootstrap as sitebootstrap - from model.guides import install_base + from sitegen.guidedata import install_base quick_install = self._quick_install() for name in sitebootstrap.SOURCES: @@ -891,7 +891,7 @@ class PackReadmesSayWhatTheInstallerDoes(unittest.TestCase): return text[text.index("INSTALLATION"):text.index("TROUBLESHOOTING")] def test_retroarch_offers_the_windows_installer(self): - from model.guides import install_ps1, install_sh + from sitegen.guidedata import install_ps1, install_sh guide = self._guide("retroarch") self.assertIn(f"{install_sh()} | sh", guide) @@ -918,7 +918,7 @@ class PackReadmesSayWhatTheInstallerDoes(unittest.TestCase): def test_retropie_never_sends_a_pc_to_the_linux_partition(self): guide = self._guide("retropie") - from model.guides import install_sh + from sitegen.guidedata import install_sh self.assertNotIn("Put the SD card in your PC", guide) self.assertIn(f"{install_sh()} | sh", guide) diff --git a/tests/test_doc_pages.py b/tests/test_doc_pages.py index 4ef4b2314..0222a1a33 100644 --- a/tests/test_doc_pages.py +++ b/tests/test_doc_pages.py @@ -928,7 +928,7 @@ class RetroArchWindowsSystemFolder(unittest.TestCase): source = inspect.getsource(install) self.assertIn('ra_dir or exe_dir / "system"', source) self.assertTrue(str(install._os_default_dests("windows")["retroarch"]).replace("\\", "/").endswith("/system")) - from model.guides import platform_guides + from sitegen.guidedata import platform_guides guide = platform_guides()["retroarch"] section = "\n".join([*(path for _label, path in guide.folders), *guide.notes]) @@ -941,7 +941,7 @@ class RetroArchWindowsSystemFolder(unittest.TestCase): (platform_darwin.m), Application Support only for a portable or Steam build, and install.py looks there in that order.""" import install - from model.guides import platform_guides + from sitegen.guidedata import platform_guides source = inspect.getsource(install._macos_retroarch_base) self.assertIn('Path.home() / "Documents" / "RetroArch"', source) @@ -1645,7 +1645,7 @@ def unserved_one_liners(page: str, text: str) -> list[str]: address of the repository stays as the fallback of the One line section, and must name a bootstrap the repository holds.""" from sitegen import bootstrap as sitebootstrap - from model.guides import install_base + from sitegen.guidedata import install_base served = {f"{install_base()}/{name}" for name in sitebootstrap.SOURCES} fallback = _section(text, "One line") if page == "installer.md" else "" diff --git a/tests/test_extract_targets.py b/tests/test_extract_targets.py index 3b329d616..6af4e63da 100644 --- a/tests/test_extract_targets.py +++ b/tests/test_extract_targets.py @@ -87,7 +87,7 @@ class ThePackGuideNamesTheInstallerDefault(unittest.TestCase): # The pack guide text is data (platforms/_guides.yml): read what the # pack README prints, not the source of the script that prints it. - guide = pack_manual("retrobat") + guide = pack_manual("retrobat", PLATFORMS) self.assertEqual(first, "C:\\RetroBat\\bios") self.assertIn("(default: C:\\RetroBat\\bios\\)", guide) diff --git a/tests/test_pack_readme.py b/tests/test_pack_readme.py index 067995ff0..1738ad722 100644 --- a/tests/test_pack_readme.py +++ b/tests/test_pack_readme.py @@ -116,7 +116,7 @@ class TheOneLinerFollowsTheRegistry(unittest.TestCase): def test_the_commands_are_written_once(self): """The address comes from install_base in platforms/_guides.yml, and the one-liner from install_command, the ones the site's commands use.""" - from model.guides import install_command + from sitegen.guidedata import install_command source = (REPO_ROOT / "scripts" / "packs" / "readme.py").read_text(encoding="utf-8") for spelled in ("raw.githubusercontent.com", "abdess.github.io", "curl -fsSL", diff --git a/tests/test_release_packs.py b/tests/test_release_packs.py index 344e09c94..786731ac1 100644 --- a/tests/test_release_packs.py +++ b/tests/test_release_packs.py @@ -262,7 +262,7 @@ class TheTablesFollowTheField(unittest.TestCase): class EverySurfaceSaysWhy(unittest.TestCase): def test_a_setup_page_says_no_zip_with_the_command_beside_it(self): - from model import guides + from sitegen import guidedata from sitegen import guidepage line = guidepage.no_zip_line("KNULLI") @@ -270,7 +270,7 @@ class EverySurfaceSaysWhy(unittest.TestCase): with contextlib.chdir(REPO_ROOT): block = guidepage.pack_buttons("knulli") guide = guidepage._guide_download( - "knulli", "KNULLI", guides.platform_guides()["knulli"], None, "## Download") + "knulli", "KNULLI", guidedata.platform_guides()["knulli"], None, "## Download") self.assertIn(line, block) self.assertIn(guidepage.NO_ZIP_FAQ, block) self.assertIn(line, "\n".join(guide)) diff --git a/tests/test_site_agents.py b/tests/test_site_agents.py index 4d8742321..c2f6e79be 100644 --- a/tests/test_site_agents.py +++ b/tests/test_site_agents.py @@ -37,7 +37,7 @@ class TheGuideLeadsToTheFewestFiles(unittest.TestCase): self.assertIn("--for-games --required-only", command) def test_the_commands_are_the_ones_the_pages_show(self) -> None: - from model.guides import install_command + from sitegen.guidedata import install_command for text in (self.text, siteagents.skill_md()): for shell in ("sh", "powershell"): @@ -46,7 +46,7 @@ class TheGuideLeadsToTheFewestFiles(unittest.TestCase): text) def test_the_webmcp_tool_writes_the_same_command(self) -> None: - from model.guides import install_command + from sitegen.guidedata import install_command tools = TOOLS.read_text(encoding="utf-8") for shell in ("sh", "powershell"): diff --git a/tests/test_site_bootstrap.py b/tests/test_site_bootstrap.py index 25e45c44c..c9991b533 100644 --- a/tests/test_site_bootstrap.py +++ b/tests/test_site_bootstrap.py @@ -24,7 +24,7 @@ from unittest import mock import install from sitegen import bootstrap as sitebootstrap from model import guides -from model.guides import install_base, install_ps1, install_sh, install_command +from sitegen.guidedata import install_base, install_ps1, install_sh, install_command REPO_ROOT = Path(__file__).resolve().parents[1] diff --git a/tests/test_site_content_data.py b/tests/test_site_content_data.py index a1a5c400e..7bfbdf755 100644 --- a/tests/test_site_content_data.py +++ b/tests/test_site_content_data.py @@ -24,8 +24,10 @@ import yaml from sitegen import decorate from sitegen import nav as sitegen_nav from model import guides, siteinputs +from sitegen import guidedata from core.cli import SourceUnreadable -from model.guides import platform_guides, GuideError, load_guides +from model.guides import GuideError, load_guides +from sitegen.guidedata import platform_guides REPO_ROOT = Path(__file__).resolve().parent.parent @@ -106,10 +108,10 @@ class GuidesLiveInYaml(unittest.TestCase): self._load(_guides_text(), registry) def test_the_pack_readme_keeps_its_indent(self): - manual = guides.pack_manual("retrobat") + manual = guides.pack_manual("retrobat", REPO_ROOT / "platforms") self.assertTrue(manual.startswith(" Option B: Manual\n ----------------\n")) self.assertTrue(manual.endswith(" 4. Overwrite if asked\n\n")) - self.assertEqual(guides.pack_manual("minui"), "") + self.assertEqual(guides.pack_manual("minui", REPO_ROOT / "platforms"), "") class GuidesLoadOnFirstUse(unittest.TestCase): @@ -141,10 +143,31 @@ class GuidesLoadOnFirstUse(unittest.TestCase): before = siteinputs.current() siteinputs.use(siteinputs.SiteInputs(platforms=folder)) try: - self.assertEqual(guides.install_sh(), f"https://example.org/x/{guides.SH_NAME}") + self.assertEqual(guidedata.install_sh(), f"https://example.org/x/{guides.SH_NAME}") finally: siteinputs.use(before) - self.assertNotEqual(guides.install_base(), "https://example.org/x") + self.assertNotEqual(guidedata.install_base(), "https://example.org/x") + + def test_the_pack_readme_follows_the_platforms_folder_of_the_pack(self): + """The pack README took its manual and its commands from the site's + inputs, the repository's, while the rest of the pack came from + --platforms-dir.""" + from packs.readme import build_readme + + with tempfile.TemporaryDirectory() as tmp: + folder = Path(tmp) + (folder / "_registry.yml").write_text( + (REPO_ROOT / "platforms" / "_registry.yml").read_text(encoding="utf-8"), + encoding="utf-8") + data = yaml.safe_load(_guides_text()) + data["install_base"] = "https://example.org/x" + data["guides"]["retrobat"]["pack_manual"] = " Copy by hand.\n" + (folder / "_guides.yml").write_text(yaml.safe_dump(data), encoding="utf-8") + text = build_readme("retrobat", "RetroBat", "bios", 1, 1, + detect=[{"os": "windows"}], platforms_dir=str(folder)) + self.assertIn("irm https://example.org/x/i.ps1 | iex", text) + self.assertIn(" Copy by hand.\n", text) + self.assertNotIn(guidedata.install_base(), text) # A table of prose keyed by platform: what the guides file replaced. diff --git a/tests/test_site_demo.py b/tests/test_site_demo.py index bb8fbed4f..702f75116 100644 --- a/tests/test_site_demo.py +++ b/tests/test_site_demo.py @@ -118,7 +118,7 @@ class TheTapeAndTheDriverAgree(unittest.TestCase): self.assertEqual(variant.mount, "/roms") def test_the_command_typed_is_the_one_the_pages_give(self): - from model.guides import install_command + from sitegen.guidedata import install_command self.assertIn(f'Type "{install_command("sh", "--for-games")}"\n', self.tape) diff --git a/tests/test_site_emulators.py b/tests/test_site_emulators.py index a9fd3b179..dd8ba89e2 100644 --- a/tests/test_site_emulators.py +++ b/tests/test_site_emulators.py @@ -37,7 +37,7 @@ import yaml import tempfile import json -from model import guides +from sitegen import guidedata from sitegen import cards from sitegen import emulatorcards from sitegen import emulatorpage @@ -762,7 +762,7 @@ class InstallBlockWhereItWorks(unittest.TestCase): def test_no_os_tab_outside_the_data_root(self) -> None: if not _generated(): self.skipTest("site pages not generated") - labels = {key: guides.terminals()[key][0] for key in guides.terminals()} + labels = {key: guidedata.terminals()[key][0] for key in guidedata.terminals()} for name, profile in _profiles_with_data_root().items(): allowed = {labels["device"]} for key in profile["data_root"]: diff --git a/tests/test_site_entry.py b/tests/test_site_entry.py index da3ab26b9..00515edfc 100644 --- a/tests/test_site_entry.py +++ b/tests/test_site_entry.py @@ -55,6 +55,7 @@ from sitegen import reference from sitegen import versions from model import releaserecord from model import guides +from sitegen import guidedata from sitegen import markup as sitemarkup from model.platforms import load_platform_config from model.registry import load_platform_registry @@ -95,7 +96,7 @@ class TrustItemsSayWhereItWrites(unittest.TestCase): for entry in json.loads(path.read_text(encoding="utf-8")).get("files", [])) ] self.assertTrue(saves, "no manifest files an entry under root: save") - text = " ".join(guides.trust_items()).lower() + text = " ".join(guidedata.trust_items()).lower() self.assertNotIn("only in your bios folder", text) self.assertIn("save folder", text) self.assertIn("--restore", text) @@ -103,7 +104,7 @@ class TrustItemsSayWhereItWrites(unittest.TestCase): def test_home_shows_the_same_items(self): # A term's first use on the page carries its gloss. home = re.sub(r"]*>", "", _page("index.md")) - for item in guides.trust_items(): + for item in guidedata.trust_items(): self.assertIn(f"- {item}", home) self.assertNotIn("only in your BIOS folder", home) @@ -146,7 +147,7 @@ class DatesInWords(unittest.TestCase): class OneSetupCount(unittest.TestCase): def test_every_entry_page_states_the_registry_count(self): count = len(REGISTRY) - self.assertEqual(guides.setup_count(), count) + self.assertEqual(guidedata.setup_count(), count) self.assertIn(f"and {count - 3} more.", _page("index.md")) self.assertIn(f'{count}', _page("explore.md")) @@ -156,7 +157,7 @@ class SetupTiles(unittest.TestCase): for name in ("index.md", "which-pack.md"): text = _page(name) with self.subTest(page=name): - extra = sum(len(tiles) for tiles in guides.group_tiles().values()) + extra = sum(len(tiles) for tiles in guidedata.group_tiles().values()) self.assertEqual(text.count('class="rb-card rb-tile"'), len(REGISTRY) + extra) for key in REGISTRY: self.assertIn(f'href="/retrobios/platforms/{key}/"', text) @@ -177,7 +178,7 @@ class SetupTiles(unittest.TestCase): home = _page("index.md") display = {k: load_platform_config(k, str(REPO_ROOT / "platforms")).get("platform", k) for k in REGISTRY} - for group, (label, _description) in guides.device_groups().items(): + for group, (label, _description) in guidedata.device_groups().items(): members = [k for k in REGISTRY if REGISTRY[k].get("device_group") == group] if len(members) == 1: with self.subTest(group=group): @@ -185,9 +186,9 @@ class SetupTiles(unittest.TestCase): self.assertIn(f">{display[members[0]]}", home) def test_hardware_is_named_and_cited(self): - self.assertIn("Raspberry Pi", guides.platform_guides()["batocera"].summary) - self.assertIn("Raspberry Pi", guides.device_groups()["gaming-os"][0]) - self.assertIn("Anbernic", guides.device_groups()["handheld"][0]) + self.assertIn("Raspberry Pi", guidedata.platform_guides()["batocera"].summary) + self.assertIn("Raspberry Pi", guidedata.device_groups()["gaming-os"][0]) + self.assertIn("Anbernic", guidedata.device_groups()["handheld"][0]) lines = GUIDES_YAML.splitlines() for number, line in enumerate(lines): if re.match(r" (runs_on|terminal):", line): @@ -233,7 +234,7 @@ class GuideRoutes(unittest.TestCase): text = _page("platforms/batocera.md") self.assertLess(text.index("## From a computer"), text.index("## On the device")) self.assertIn("{ #install }", "\n".join(guidepage._guide_install( - "batocera", guides.platform_guides()["batocera"], "## On the device { #install }"))) + "batocera", guidedata.platform_guides()["batocera"], "## On the device { #install }"))) self.assertIn("Unzip them all into the network folder above", text) def test_a_computer_app_keeps_the_command_first(self): @@ -241,8 +242,8 @@ class GuideRoutes(unittest.TestCase): self.assertLess(text.index("## Install"), text.index("## Download")) def test_each_device_tab_says_how_to_open_its_terminal(self): - shared = guides.terminals()["device"][1] - for name, guide in guides.platform_guides().items(): + shared = guidedata.terminals()["device"][1] + for name, guide in guidedata.platform_guides().items(): if "device" not in guide.run: continue with self.subTest(platform=name): @@ -265,17 +266,17 @@ class GuideRoutes(unittest.TestCase): class PackManualReadsThePageFolders(unittest.TestCase): def test_every_path_in_a_pack_manual_is_a_folder_of_its_page(self): - for name, guide in guides.platform_guides().items(): + for name, guide in guidedata.platform_guides().items(): if not guide.pack_manual: continue - known = " ".join(path.replace("`", "") for _w, path in guides.folder_list(name)) + known = " ".join(path.replace("`", "") for _w, path in guidedata.folder_list(name)) known += " " + str(REGISTRY[name].get("extract_to") or "") - for path in ABSOLUTE_PATH.findall(guides.pack_manual(name)): + for path in ABSOLUTE_PATH.findall(guides.pack_manual(name, REPO_ROOT / "platforms")): with self.subTest(platform=name, path=path): self.assertIn(path.rstrip(".:"), known) def test_the_retroarch_manual_lists_the_detected_systems(self): - manual = guides.pack_manual("retroarch") + manual = guides.pack_manual("retroarch", REPO_ROOT / "platforms") self.assertNotIn("{folders}", manual) self.assertIn("/run/muos/storage/bios", manual) self.assertIn("~/.var/app/org.libretro.RetroArch/config/retroarch/system/", manual) @@ -326,7 +327,7 @@ class CommandBlocks(unittest.TestCase): self.assertEqual(sorted(set(sh_args)), sorted(set(ps_args))) self.assertEqual(len(set(sh_args)), 2) self.assertIn('```powershell title="PowerShell"', block) - for key, guide in guides.platform_guides().items(): + for key, guide in guidedata.platform_guides().items(): if "windows" in guide.run: with self.subTest(platform=key): self.assertIn("/i.ps1", _guide_part(_page(f"platforms/{key}.md"))) @@ -360,7 +361,7 @@ class HomeLinksTheOtherTasks(unittest.TestCase): self.assertLess(home.index("/retrobios/wiki/troubleshooting/"), home.index("## Is it needed? { #do-i-need-it }")) -GUIDE = guides.handheld_guide() +GUIDE = guidedata.handheld_guide() def _plain_guide_part(text: str) -> str: @@ -376,7 +377,7 @@ def _display(key: str) -> str: class HandheldWayIn(unittest.TestCase): def test_android_and_linux_tiles_on_home_and_get_your_files(self): - tiles = guides.group_tiles().get("handheld", ()) + tiles = guidedata.group_tiles().get("handheld", ()) self.assertEqual([tile.name for tile in tiles], ["Android", "Linux handhelds", "iPhone and iPad"]) for name in ("index.md", "which-pack.md"): @@ -432,7 +433,7 @@ class HandheldWayIn(unittest.TestCase): data = {"page": "x", "title": "X", "summary": "S", "uses": "retroarch", "systems": [{"name": "Onion"}]} with self.assertRaises(guides.GuideError): - guides._handheld_guide(data, REGISTRY, guides.platform_guides(), "x") + guides._handheld_guide(data, REGISTRY, guidedata.platform_guides(), "x") def test_devices_are_a_search_field_with_no_text(self): text = _page(GUIDE.path) @@ -450,7 +451,7 @@ class HandheldWayIn(unittest.TestCase): setup = next(tab["Setups"] for tab in nav if "Setups" in tab) groups = {next(iter(item)): next(iter(item.values())) for item in setup if isinstance(item, dict)} - label = guides.device_groups()["handheld"][0] + label = guidedata.device_groups()["handheld"][0] self.assertIn({GUIDE.title: GUIDE.path}, groups[label]) def test_the_guide_fills_the_card_and_never_its_root(self): @@ -672,7 +673,7 @@ class DownloadLine(unittest.TestCase): self.assertRegex(line, r"\[SHA256SUMS\.txt\]\([^)]+\) and its \[signature\]\([^)]+\)\.$") -HANDHELDS = guides.handheld_guide() +HANDHELDS = guidedata.handheld_guide() OFFLINE_ANCHOR = "#without-a-network-offline-install" @@ -686,7 +687,7 @@ def _with_zip(name: str) -> bool: return bool(pack and pack.get("assets")) -SETUPS = [name for name in guides.platform_guides() if name in REGISTRY] +SETUPS = [name for name in guidedata.platform_guides() if name in REGISTRY] class NoZipNoUnzipText(unittest.TestCase): @@ -742,9 +743,9 @@ class NoZipNoUnzipText(unittest.TestCase): def test_the_network_route_needs_a_share_and_no_zip(self): for name in SETUPS: - share = guidepage._network_share(name, guides.platform_guides()[name]) + share = guidepage._network_share(name, guidedata.platform_guides()[name]) with self.subTest(setup=name): - if _with_zip(name) or guides.platform_guides()[name].run != ("device",): + if _with_zip(name) or guidedata.platform_guides()[name].run != ("device",): self.assertEqual(share, "") if share: self.assertTrue(share.startswith("\\\\")) @@ -818,7 +819,7 @@ class EntryCopy(unittest.TestCase): def test_the_setup_index_lists_the_handheld_tiles(self): text = _plain_page("platforms/index.md") - for tile in guides.group_tiles()["handheld"]: + for tile in guidedata.group_tiles()["handheld"]: target = tile.link.removesuffix(".md").replace(".md#", "/#") with self.subTest(tile=tile.name): self.assertIn(f"**[{tile.name}](/retrobios/{target}", text.replace("/)", ")")) @@ -827,7 +828,7 @@ class EntryCopy(unittest.TestCase): class IphoneAndIpad(unittest.TestCase): def test_a_tile_in_the_handheld_group(self): - tile = next(t for t in guides.group_tiles()["handheld"] if t.name == "iPhone and iPad") + tile = next(t for t in guidedata.group_tiles()["handheld"] if t.name == "iPhone and iPad") self.assertEqual(tile.link, "which-pack.md#iphone-and-ipad") for name in ("index.md", "which-pack.md"): with self.subTest(page=name): @@ -884,18 +885,18 @@ class GetPagesGiveTheSetupsOwnRoutes(unittest.TestCase): def test_a_card_setup_names_the_card(self): for name in SETUPS: - if not guides.platform_guides()[name].on_card: + if not guidedata.platform_guides()[name].on_card: continue with self.subTest(setup=name): for command in COMMAND.findall(_plain_page(f"get/{name}.md")): self.assertIn("--dest ", command) def test_no_tab_for_a_system_the_setup_does_not_run_from(self): - labels = {key: entry[0] for key, entry in guides.terminals().items()} + labels = {key: entry[0] for key, entry in guidedata.terminals().items()} for name in SETUPS: if _with_zip(name): continue - guide = guides.platform_guides()[name] + guide = guidedata.platform_guides()[name] allowed = {labels[key] for key in guide.run} allowed |= {labels[key] for key in guide.card_run or ("windows", "macos", "linux")} if guidepage._network_share(name, guide): @@ -938,7 +939,7 @@ class CheckNeedsTheFiles(unittest.TestCase): class ARouteWithoutANetwork(unittest.TestCase): def test_every_setup_page_has_the_offline_line_or_the_card_route(self): for name in SETUPS: - guide = guides.platform_guides()[name] + guide = guidedata.platform_guides()[name] text = _guide_part(_plain_page(f"platforms/{name}.md")) with self.subTest(setup=name): if _with_zip(name): @@ -951,7 +952,7 @@ class ARouteWithoutANetwork(unittest.TestCase): def test_every_device_setup_with_no_zip_links_the_card_answer(self): for name in SETUPS: - guide = guides.platform_guides()[name] + guide = guidedata.platform_guides()[name] if _with_zip(name) or guide.run != ("device",): continue extract_to = REGISTRY[name]["extract_to"] @@ -968,7 +969,7 @@ class ARouteWithoutANetwork(unittest.TestCase): self.assertLess(text.index("## From a computer"), text.index("## On the device")) def test_retropie_card_is_read_from_linux_only(self): - self.assertEqual(guides.platform_guides()["retropie"].card_run, ("linux",)) + self.assertEqual(guidedata.platform_guides()["retropie"].card_run, ("linux",)) text = _plain_page("platforms/retropie.md") card = text.split("No network?", 1)[1].split("## On the device", 1)[0] # One system, so no tab bar: its label leads the command. @@ -981,7 +982,7 @@ class ARouteWithoutANetwork(unittest.TestCase): folder neither can open.""" for name in ("lakka", "retropie"): with self.subTest(setup=name): - self.assertEqual(guides.platform_guides()[name].card_run, ("linux",)) + self.assertEqual(guidedata.platform_guides()[name].card_run, ("linux",)) card = _plain_page(f"platforms/{name}.md").split("No network?", 1)[1] card = card.split("## On the device", 1)[0] self.assertEqual(_tab_labels(card), set()) @@ -1039,7 +1040,7 @@ class GetPagesSayWhatTheyHold(unittest.TestCase): class HandheldRowsSayWhere(unittest.TestCase): def test_retrooz_names_its_folder_with_a_pinned_source(self): - system = next(s for s in guides.handheld_guide().systems if s.name == "RetroOZ") + system = next(s for s in guidedata.handheld_guide().systems if s.name == "RetroOZ") self.assertIn("`/roms/bios`", system.folder) self.assertRegex(system.folder_source, r"/wiki/Home/[0-9a-f]{40}$") row = next(line for line in _plain_page("platforms/linux-handhelds.md").splitlines() @@ -1053,7 +1054,7 @@ class GetIndex(unittest.TestCase): for name in SETUPS: with self.subTest(setup=name): self.assertIn(f"(/retrobios/get/{name}/)", text) - for label, _description in guides.device_groups().values(): + for label, _description in guidedata.device_groups().values(): self.assertIn(f"## {label}", text) diff --git a/tests/test_site_funnel.py b/tests/test_site_funnel.py index 1f1e0cafa..04e713649 100644 --- a/tests/test_site_funnel.py +++ b/tests/test_site_funnel.py @@ -22,7 +22,7 @@ from sitegen import whichpack from tests import sitepages from model.registry import list_registered_platforms, load_platform_registry from model.platforms import load_platform_config -from model.guides import device_groups, group_anchors, platform_guides +from sitegen.guidedata import device_groups, group_anchors, platform_guides REPO_ROOT = Path(__file__).resolve().parent.parent @@ -137,7 +137,7 @@ class EveryPlatformOnThePicker(unittest.TestCase): def test_handheld_systems_that_run_retroarch_are_named(self): """muOS, ArkOS and the rest are detected as RetroArch by the installer and were named on no page a user reads.""" - from model.guides import handheld_guide + from sitegen.guidedata import handheld_guide page = guidepage.generate_handheld_guide(handheld_guide()) self.assertIn("| muOS |", page) diff --git a/tests/test_site_handheld.py b/tests/test_site_handheld.py index e6f716bb5..7ee6ceea2 100644 --- a/tests/test_site_handheld.py +++ b/tests/test_site_handheld.py @@ -104,11 +104,11 @@ class WhereEachSystemFindsItsFile(unittest.TestCase): def test_the_group_page_sits_with_the_handheld_guide(self): """It shares the guide's name, so the sidebar files it with it, and the guide a muOS or ArkOS owner lands on links it.""" - from model import guides + from sitegen import guidedata from sitegen import getpages from sitegen import guidepage - guide = guides.handheld_guide() + guide = guidedata.handheld_guide() self.assertEqual(handhelds.GROUP_PAGE, guide.page) with contextlib.chdir(REPO_ROOT): self.assertIn(f"(../get/{handhelds.GROUP_PAGE}.md)", diff --git a/tests/test_site_integration.py b/tests/test_site_integration.py index 0b674e2b4..73b19c474 100644 --- a/tests/test_site_integration.py +++ b/tests/test_site_integration.py @@ -87,7 +87,7 @@ class PlatformLogos(unittest.TestCase): self.assertTrue(self.registry["minui"]["logo_flip"]) def test_every_logo_copy_has_a_registry_or_tile_logo(self): - from model.guides import group_tiles + from sitegen.guidedata import group_tiles tiles = {re.sub(r"[^a-z0-9]+", "-", tile.name.lower()).strip("-"): tile.logo for group in group_tiles().values() for tile in group} diff --git a/tests/test_site_nav.py b/tests/test_site_nav.py index e09d7e1ff..e6407e43a 100644 --- a/tests/test_site_nav.py +++ b/tests/test_site_nav.py @@ -43,7 +43,7 @@ from core import anchors as core_anchors from model.registry import list_registered_platforms, load_platform_registry from model.platforms import load_platform_config -from model.guides import device_groups +from sitegen.guidedata import device_groups REPO_ROOT = Path(__file__).resolve().parents[1] @@ -476,7 +476,7 @@ def _moved_platform_pages() -> list[Path]: return [] # A guide page sits beside the setups (platforms/linux-handhelds) without # being a list moved off one of them. - from model.guides import handheld_guide + from sitegen.guidedata import handheld_guide handhelds = handheld_guide() guides = {Path(handhelds.path).stem} if handhelds else set() diff --git a/tests/test_site_page_text.py b/tests/test_site_page_text.py index d5d985df2..017563ecb 100644 --- a/tests/test_site_page_text.py +++ b/tests/test_site_page_text.py @@ -25,7 +25,7 @@ from pathlib import Path from sitegen import diagrams from sitegen import entries as siteentries from sitegen import steps as sitesteps -from model.guides import terminals +from sitegen.guidedata import terminals ROOT = Path(__file__).resolve().parent.parent diff --git a/tests/test_site_steps.py b/tests/test_site_steps.py index b636daf52..c1ce977d5 100644 --- a/tests/test_site_steps.py +++ b/tests/test_site_steps.py @@ -18,7 +18,7 @@ from pathlib import Path from sitegen import diagrams from sitegen import steps as sitesteps -from model.guides import terminals +from sitegen.guidedata import terminals ROOT = Path(__file__).resolve().parent.parent diff --git a/tests/test_site_wiki.py b/tests/test_site_wiki.py index db3119dca..3b70d6243 100644 --- a/tests/test_site_wiki.py +++ b/tests/test_site_wiki.py @@ -46,7 +46,7 @@ from pathlib import Path import yaml from sitegen import diagrams, ogcards, pageprep -from model.guides import install_sh +from sitegen.guidedata import install_sh from tests import sitepages from installer_build import port from installer_build.module import installer_module