mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-01 13:58:55 -06:00
refactor: split generate_site into sitegen modules
This commit is contained in:
1 parent
231002a7c0
commit
4e50286d8c
78 files changed
+15084
-14289
No files matched your search
@@ -0,0 +1,94 @@
|
||||
"""The platforms index and the setup table."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import release_record
|
||||
from model.guides import DEVICE_GROUPS, GROUP_TILES, GUIDES
|
||||
from resolve.nativemode import check_label
|
||||
from sitegen import markup
|
||||
from sitegen.guidepage import NO_ZIP_FAQ
|
||||
from sitegen.home import _group_members
|
||||
from sitegen.install import has_release_pack
|
||||
from sitegen.readme import release_totals
|
||||
|
||||
|
||||
# Platform pages
|
||||
|
||||
|
||||
def generate_platform_index(coverages: dict, registry: dict | None = None) -> str:
|
||||
"""The Setups tab: every platform by the device it runs on, and one
|
||||
line to the table that sets them side by side (setup_table), which is
|
||||
reference matter and sits with how each setup checks its files."""
|
||||
registry = registry or {}
|
||||
lines = [
|
||||
"# Setups",
|
||||
"",
|
||||
"Each setup's page gives the folder and the command.",
|
||||
"",
|
||||
]
|
||||
for group, (label, _description) in DEVICE_GROUPS.items():
|
||||
members = _group_members(coverages, registry, group)
|
||||
if not members:
|
||||
continue
|
||||
# The group label names the devices, and each card carries its
|
||||
# setup's own sentence. The kinds of device that run a setup
|
||||
# follow, as on the home tiles.
|
||||
lines += [f"## {label}", ""]
|
||||
lines += markup.card_grid([
|
||||
*((f"[{coverages[name]['platform']}]({name}.md)", [GUIDES[name].summary])
|
||||
for name in members),
|
||||
*((f"[{tile.name}](../{tile.link})", [tile.text])
|
||||
for tile in GROUP_TILES.get(group, ())),
|
||||
])
|
||||
lines += [
|
||||
f"Comparing setups? [Every setup side by side](../{SETUP_TABLE_LINK})",
|
||||
"",
|
||||
]
|
||||
return "\n".join(lines) + "\n"
|
||||
|
||||
|
||||
# Where the side-by-side table of setups is published: with how each setup
|
||||
# checks its files, the column a reader compares.
|
||||
SETUP_TABLE_PAGE = "wiki/verification-modes.md"
|
||||
SETUP_TABLE_ANCHOR = "every-setup-at-a-glance"
|
||||
SETUP_TABLE_LINK = f"{SETUP_TABLE_PAGE}#{SETUP_TABLE_ANCHOR}"
|
||||
|
||||
|
||||
def setup_table(coverages: dict) -> list[str]:
|
||||
"""Every setup side by side: the files on its own list, the files in its
|
||||
ZIP, and how it checks them. Written under the Reference level, on the
|
||||
page that explains each way of checking."""
|
||||
lines = [
|
||||
f"## Every setup at a glance {{ #{SETUP_TABLE_ANCHOR} }}",
|
||||
"",
|
||||
"| Setup | Files on its own list | Files in the ZIP | How it checks |",
|
||||
"|-------|------:|------:|---------------|",
|
||||
]
|
||||
for name, cov in sorted(coverages.items(), key=lambda item: item[1]["platform"].casefold()):
|
||||
listed = f"{cov['total']:,}" if cov["total"] else "No list of its own"
|
||||
files, _size = release_totals(name, release_record.load_advertised())
|
||||
zipped = (f"{files:,}" if files
|
||||
else "No ZIP yet" if has_release_pack(name) else "No ZIP")
|
||||
lines.append(
|
||||
f"| [{cov['platform']}](../platforms/{name}.md) | {listed} | {zipped} | "
|
||||
f"{check_label(cov['mode'], cov['config'].get('hash_rule'))} |"
|
||||
)
|
||||
lines += [
|
||||
"",
|
||||
"The ZIP adds the files its emulators load to the files on the setup's own list.",
|
||||
"",
|
||||
]
|
||||
lines += ["No ZIP: the setup is served by the command alone. "
|
||||
f"[Why?](../{NO_ZIP_FAQ})", ""]
|
||||
return lines
|
||||
|
||||
|
||||
def with_setup_table(page: str, coverages: dict) -> str:
|
||||
"""The comparison table placed before the Next steps of its page, or at
|
||||
its end."""
|
||||
table = "\n".join(setup_table(coverages))
|
||||
marker = "\n## Next steps"
|
||||
if marker in page:
|
||||
head, tail = page.split(marker, 1)
|
||||
return f"{head.rstrip()}\n\n{table}{marker}{tail}"
|
||||
return f"{page.rstrip()}\n\n{table}"
|
||||
Reference in new issue
Block a user