mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-24 12:49:03 -05:00
generate_site.py writes the Starlight project in website/ and nothing else: mkdocs.yml, the MkDocs hooks, theme overrides and stylesheet go, and the wiki is written in Starlight's syntax. Both workflows set up Node with the official actions/setup-node pinned by commit, run npm ci from the committed lockfile, build with the strict link validator and check the result with validate_site.py. The search weighs a page by what it answers: Start here pages first, a system page's cards and file names before a guide citing them, deep guides, launchers, aliases and frozen copies after. Status badges, hash blocks and the export change lists leave the index. The ranking sits at the centre of a range where the 13 queries of search_gate.py all answer, in the search box itself. 839 pages, every URL and 45,611 ids match the MkDocs build. The tests read the Starlight content and syntax.
75 lines
2.7 KiB
Python
75 lines
2.7 KiB
Python
"""The site counts a platform's cores the way the builder resolves them.
|
|
|
|
The cross-reference page re-implemented the resolution and dropped the
|
|
libretro set a cores: list naming retroarch pulls in: RetroDECK read 20 cores
|
|
where its pack is built from 321.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
|
|
|
import generate_site # noqa: E402
|
|
from common import ( # noqa: E402
|
|
list_registered_platforms,
|
|
load_emulator_profiles,
|
|
load_platform_config,
|
|
resolve_platform_cores,
|
|
)
|
|
|
|
|
|
class SiteCoreCounts(unittest.TestCase):
|
|
def test_each_platform_count_is_the_resolved_set(self):
|
|
platforms = str(REPO_ROOT / "platforms")
|
|
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
|
unique = {k: v for k, v in profiles.items() if v.get("type") not in ("alias", "test")}
|
|
coverages = {}
|
|
for name in list_registered_platforms(platforms, include_archived=True):
|
|
config = load_platform_config(name, platforms)
|
|
coverages[name] = {"platform": config.get("platform", name), "config": config}
|
|
page = generate_site.generate_cross_reference(coverages, profiles)
|
|
shown = {
|
|
m.group(1): int(m.group(2))
|
|
for m in re.finditer(
|
|
r'<summary>([^<]+)</summary>\n\n.*\n\n\*\*(\d+) cores', page)
|
|
}
|
|
for name, cov in coverages.items():
|
|
with self.subTest(platform=name):
|
|
expected = len(resolve_platform_cores(cov["config"], unique))
|
|
self.assertEqual(shown[cov["platform"]], expected)
|
|
|
|
|
|
class AllLibretroLabel(unittest.TestCase):
|
|
"""RetroPie and RetroDECK pull in every libretro core by naming retroarch
|
|
in a list, and the label read "(all libretro)" for RetroArch and Lakka
|
|
only, the two whose cores: is the string."""
|
|
|
|
PROFILES = {
|
|
"a": {"type": "libretro"},
|
|
"b": {"type": "standalone + libretro"},
|
|
"sa": {"type": "standalone"},
|
|
}
|
|
|
|
def test_a_list_naming_retroarch_is_labelled(self):
|
|
note = generate_site._core_scope_note(
|
|
{"cores": ["retroarch", "sa"]}, self.PROFILES)
|
|
self.assertEqual(note, " (all libretro, plus 1 other core)")
|
|
|
|
def test_the_string_form_is_labelled(self):
|
|
note = generate_site._core_scope_note({"cores": "all_libretro"}, self.PROFILES)
|
|
self.assertEqual(note, " (all libretro)")
|
|
|
|
def test_a_selection_is_not(self):
|
|
self.assertEqual(
|
|
generate_site._core_scope_note({"cores": ["a", "sa"]}, self.PROFILES), "")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|