fix: settle the round 3 site packages together

This commit is contained in:
Abdessamad Derraz committed 2026-10-23 11:12:12 +02:00
1 parent d168ceb8a8
commit f0e7d87def
10 files changed
+44 -11

No files matched your search

+3
View File
@@ -88,6 +88,8 @@ class TablesStackWhenBuilt(unittest.TestCase):
"reference": {"labels": ["A", "B", "C"], "rows": 5, "action": False, "level": "reference"},
# Four columns do not fit a phone column, on any page (round 3).
"wide": {"labels": ["File", "Region", "Required", "Hash"], "rows": 105, "action": False, "level": "reference"},
# A hash never breaks: three columns with one overflow a phone (NetherSX2).
"hashes": {"labels": ["File", "Required", "Hash"], "rows": 40, "action": False, "level": "reference"},
}
script = (
f"import {{ stackKind }} from {json.dumps(PLUGIN.as_uri())};"
@@ -101,6 +103,7 @@ class TablesStackWhenBuilt(unittest.TestCase):
self.assertEqual(json.loads(result.stdout), {
"zip-header": "true", "action": "true", "pair": "kv",
"short-start": "true", "long-setup": None, "reference": None, "wide": "true",
"hashes": "true",
})
+14 -1
View File
@@ -45,6 +45,16 @@ _ELEMENT = re.compile(r"<[a-zA-Z][a-zA-Z0-9-]*[\s/>]")
_TAGS = re.compile(r"<[^>]+>")
_TABLE = re.compile(r"<table\b(?P<attrs>[^>]*)>(?P<body>.*?)</table>", re.S)
_CURRENT = re.compile(r'<a\b[^>]*aria-current="page"[^>]*>(?P<label>.*?)</a>', re.S)
_CURRENT_HREF = re.compile(r'<a\b(?=[^>]*aria-current="page")[^>]*href="(?P<href>[^"]*)"', re.S)
def _marked_parent(html: str, url: str) -> str | None:
"""The page a part page names as its parent. The sidebar marks that page
instead of the part, and the last crumb leads to it."""
found = _CURRENT_HREF.search(html.split('id="starlight__sidebar"', 1)[-1])
if found and found["href"].rstrip("/") != url.rstrip("/"):
return found["href"]
return None
_H1 = re.compile(r"<h1\b[^>]*>(?P<title>.*?)</h1>", re.S)
_HEADING = re.compile(r"<h(?P<level>[2-6])\b[^>]*>(?P<inner>.*?)</h(?P=level)>", re.S)
_CRUMBS = re.compile(r'<nav\b[^>]*aria-label="Breadcrumb"[^>]*>(?P<inner>.*?)</nav>', re.S)
@@ -128,6 +138,8 @@ class EveryBuiltPage(unittest.TestCase):
# A tab, or a group of the sidebar, opens on its overview.
if url in self.tab_roots or url in self.group_pages or not current or not title:
continue
if _marked_parent(html, url):
continue
with self.subTest(page=url):
self.assertEqual(_text(current["label"]), _text(title["title"]))
@@ -144,10 +156,11 @@ class EveryBuiltPage(unittest.TestCase):
crumbs = _CRUMBS.search(html)
if not crumbs:
continue
parent = _marked_parent(html, _url(path))
for href in _HREF.findall(crumbs["inner"]):
with self.subTest(page=_url(path), href=href):
self.assertTrue(href in self.tab_roots or href in self.group_pages
or "#" in href, href)
or "#" in href or href == parent, href)
def test_phone_tables_on_reader_pages_are_stacked(self):
"""A table of three columns or more, under RECORD_ROWS rows, on a
+4
View File
@@ -291,7 +291,11 @@ class PlatformShareCards(unittest.TestCase):
def test_other_pages_keep_their_section_card(self):
self.assertEqual(sitestarlight.og_image("platforms/index.md", "setup"),
f"{sitestarlight.SITE_URL}assets/og/setup.png")
# A manufacturer page has its own card since round 3 (6.6); one
# without a rendered card keeps its section's.
self.assertEqual(sitestarlight.og_image("systems/sony.md", "explore"),
f"{sitestarlight.SITE_URL}assets/og/systems/sony.png")
self.assertEqual(sitestarlight.og_image("systems/no-such-maker.md", "explore"),
f"{sitestarlight.SITE_URL}assets/og/explore.png")
+3 -3
View File
@@ -181,9 +181,9 @@ class OfflineLine(unittest.TestCase):
line = text.index("No internet on the device?")
self.assertLess(start, line)
self.assertLess(line, text.index("## On the device"))
self.assertIn("/retrobios/wiki/installer/#without-a-network", text)
self.assertIn("{ #without-a-network }", (REPO_ROOT / "wiki" / "installer.md").read_text(
encoding="utf-8"))
self.assertIn("/retrobios/wiki/installer/#without-a-network-offline-install", text)
self.assertIn("{ #without-a-network-offline-install }",
(REPO_ROOT / "wiki" / "installer.md").read_text(encoding="utf-8"))
class GetYourFilesListsEachSetupOnce(unittest.TestCase):
+6 -1
View File
@@ -51,8 +51,13 @@ def _moved_platform_pages() -> list[Path]:
folder = DOCS / "platforms"
if not folder.is_dir():
return []
# A guide page sits beside the setups (platforms/linux-handhelds) without
# being a list moved off one of them.
from siteguides import HANDHELD_GUIDE # noqa: PLC0415
guides = {Path(HANDHELD_GUIDE.path).stem} if HANDHELD_GUIDE else set()
return [path for path in sorted(folder.glob("*.md*"))
if path.stem not in platforms and path.stem != "index"]
if path.stem not in platforms and path.stem != "index" and path.stem not in guides]
class MetaFields(unittest.TestCase):