refactor: tidy the repository root
README.md and CONTRIBUTING.md open with a comment naming their generator, generate_readme.py --check fails on a hand edit in validate.yml and pr_checks.py, and .gitattributes marks the pipeline outputs as generated, held equal to core/generated.py by a test. _mame_clones.json becomes mame_clones.json, still written beside the scanned bios/ tree, and now triggers both workflows (coverage reads it). docs_assets/ moves to website/assets/, which Astro does not read as content. ACCESSIBILITY.md becomes wiki/accessibility.md, linked from the README and the installer page. The screenshot list moves to wiki/images-wanted.md: nothing read docs_assets/screens/. The architecture map names every root entry (test_repository_map), platforms/README.md keeps only what this folder holds, the reference index lists archive-recipes and measurements, and reference-terms no longer defines Profile twice nor repeats the glossary's Pack.
No files matched your search
@@ -25,3 +25,24 @@ data/** -text
|
||||
# Measurement records are append-only: two branches that each add a line to
|
||||
# the same file merge by keeping both.
|
||||
measurements/*.jsonl text eol=lf merge=union
|
||||
|
||||
# What a pipeline run writes (scripts/core/generated.py, GENERATED), folded in
|
||||
# review diffs and left out of the language statistics. Anchored with a slash:
|
||||
# a bare README.md would match platforms/README.md too. A test holds this list
|
||||
# equal to GENERATED.
|
||||
/database.json linguist-generated=true
|
||||
/derivable.json linguist-generated=true
|
||||
/retired.json linguist-generated=true
|
||||
/install/*.json linguist-generated=true
|
||||
/install/standalone/*.json linguist-generated=true
|
||||
/install/targets/*.json linguist-generated=true
|
||||
/install/games/*.json linguist-generated=true
|
||||
/install/games/*/*.json linguist-generated=true
|
||||
/README.md linguist-generated=true
|
||||
/CONTRIBUTING.md linguist-generated=true
|
||||
/wiki/installer.md linguist-generated=true
|
||||
/wiki/reading-reports.md linguist-generated=true
|
||||
/website/src/data/*.json linguist-generated=true
|
||||
/recipes/archives.json linguist-generated=true
|
||||
/exports/*.json linguist-generated=true
|
||||
/exports/*/*.json linguist-generated=true
|
||||
@@ -242,7 +242,6 @@ on:
|
||||
- "scripts/validate_schemas.py"
|
||||
- "scripts/validate_site.py"
|
||||
- "schemas/**"
|
||||
- "docs_assets/**"
|
||||
- "install/**"
|
||||
# The site serves install.sh and install.ps1 pinned to install.py
|
||||
# of the commit it is built from (scripts/sitegen/bootstrap.py).
|
||||
@@ -256,6 +255,8 @@ on:
|
||||
- "database.json"
|
||||
- "release.json"
|
||||
- "derivable.json"
|
||||
# The coverage counts resolve MAME clones through it.
|
||||
- "mame_clones.json"
|
||||
- "retired.json"
|
||||
# The README and the archive recipes page count the recipes.
|
||||
- "recipes/archives.json"
|
||||
|
||||
@@ -26,13 +26,13 @@ on:
|
||||
# Every input of the site build, so a page that would fail the deploy
|
||||
# fails here first (tests/test_workflow_paths.py).
|
||||
- "wiki/**"
|
||||
- "docs_assets/**"
|
||||
- "provenance/**"
|
||||
- "exports/**"
|
||||
- "install/**"
|
||||
- "database.json"
|
||||
- "release.json"
|
||||
- "derivable.json"
|
||||
- "mame_clones.json"
|
||||
- "retired.json"
|
||||
- "recipes/**"
|
||||
- "measurements/**"
|
||||
@@ -40,6 +40,9 @@ on:
|
||||
- "website/**"
|
||||
# The type check's and the lint's configuration.
|
||||
- "pyproject.toml"
|
||||
# Generated files: a hand edit fails the regeneration check.
|
||||
- "README.md"
|
||||
- "CONTRIBUTING.md"
|
||||
# Spelled out twice because the workflow parser reads no YAML anchor. A test
|
||||
# holds the two lists equal.
|
||||
push:
|
||||
@@ -58,19 +61,21 @@ on:
|
||||
- "ports/**"
|
||||
- "packaging/**"
|
||||
- "wiki/**"
|
||||
- "docs_assets/**"
|
||||
- "provenance/**"
|
||||
- "exports/**"
|
||||
- "install/**"
|
||||
- "database.json"
|
||||
- "release.json"
|
||||
- "derivable.json"
|
||||
- "mame_clones.json"
|
||||
- "retired.json"
|
||||
- "recipes/**"
|
||||
- "measurements/**"
|
||||
- "campaign/**"
|
||||
- "website/**"
|
||||
- "pyproject.toml"
|
||||
- "README.md"
|
||||
- "CONTRIBUTING.md"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -197,6 +202,15 @@ jobs:
|
||||
- name: Check that install.py is the one installer/ builds
|
||||
run: python scripts/build_installer.py --check
|
||||
|
||||
# README.md and CONTRIBUTING.md are written by scripts/sitegen/readme.py.
|
||||
# Deploy Site compared them only after the merge, and only when another
|
||||
# path triggered it: a hand edit to either file reached main unchecked.
|
||||
# Offline, the contributors section is read back from the file.
|
||||
- name: Check that README and CONTRIBUTING are the generated ones
|
||||
env:
|
||||
RETROBIOS_OFFLINE: "1"
|
||||
run: python scripts/generate_readme.py --db database.json --platforms-dir platforms --check
|
||||
|
||||
# A profile written from a clone can cite lines that do not hold the value
|
||||
# it declares, and schemas and tests pass it. Each profile a change adds is
|
||||
# confronted with its upstream, both roads into main. An edited profile is
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<!-- Generated by scripts/generate_readme.py from scripts/sitegen/readme.py. Edit the generator, then run it: a hand edit fails the Validation workflow. -->
|
||||
# Contributing to RetroBIOS
|
||||
|
||||
## Add a BIOS file
|
||||
@@ -96,6 +97,8 @@ python scripts/validate_schemas.py --source-only # profiles and platf
|
||||
mypy # no type error in install.py, installer/ and scripts/
|
||||
ruff check . # the lint rules of pyproject.toml
|
||||
python scripts/build_installer.py --check # install.py is the one installer/ builds
|
||||
# README.md and CONTRIBUTING.md are the generated ones
|
||||
python scripts/generate_readme.py --db database.json --platforms-dir platforms --check
|
||||
python scripts/profile_sync.py --added --strict # each profile the branch adds
|
||||
vermin --no-tips -t=3.8- --violations install.py installer # the installer stays on Python 3.8
|
||||
shellcheck --version # the launcher test runs shellcheck
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<!-- Generated by scripts/generate_readme.py from scripts/sitegen/readme.py. Edit the generator, then run it: a hand edit fails the Validation workflow. -->
|
||||
<p align="center">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset=".github/assets/banner-dark.svg">
|
||||
@@ -31,7 +32,7 @@ curl -fsSL https://abdess.github.io/retrobios/i | sh
|
||||
|
||||
**A handheld, an SD card, or not sure?** [Pick the device](https://abdess.github.io/retrobios/which-pack/): its page gives the folder and the command. A muOS, Onion, spruceOS, MinUI, KNULLI, ROCKNIX, Lakka or MiSTer SD card plugged into the computer is found by itself.
|
||||
|
||||

|
||||

|
||||
|
||||
The installer finds the setup and its BIOS folder, installs the files it needs (only what the games need when it finds them on the card) and checks each one. Its screen installs everything, or fewer under **Choose systems**. Arrow keys and Enter drive it, or a controller on a handheld. It sends no report of its own ([what is counted](https://abdess.github.io/retrobios/wiki/privacy/)). Options go after the line in the form the [installer page](https://abdess.github.io/retrobios/wiki/installer/#passing-options) gives.
|
||||
|
||||
@@ -60,6 +61,7 @@ Unzip into the BIOS folder, files straight in it. A big pack comes in parts (`Pa
|
||||
- Have a file? [Check it by its hash](https://abdess.github.io/retrobios/files/)
|
||||
- Every console and the files it needs: [systems](https://abdess.github.io/retrobios/systems/)
|
||||
- Asking an AI assistant: it reads the site best from [llms.txt](https://abdess.github.io/retrobios/llms.txt)
|
||||
- Screen reader, keyboard only or no colour: [accessibility](https://abdess.github.io/retrobios/wiki/accessibility/)
|
||||
|
||||
## How it is built
|
||||
|
||||
@@ -109,4 +111,4 @@ The scripts and tooling are released under the [MIT License](LICENSE).
|
||||
The BIOS and firmware files are not covered by that license: they are third-party system software, preserved and provided for personal backup, archival, and interoperability with emulation software. [NOTICE](NOTICE) sets out their status and how to ask for a file to be removed.
|
||||
The reasoning, and where it is weakest, is in [the project's legal position](https://abdess.github.io/retrobios/wiki/legal/).
|
||||
|
||||
*Auto-generated on 2026-11-23T22:25:21Z*
|
||||
*Auto-generated on 2026-11-24T08:57:19Z*
|
||||
@@ -1,55 +1,49 @@
|
||||
# Platform Configs
|
||||
# Platform configs
|
||||
|
||||
How platform YAML files work and where subdirectory requirements come from.
|
||||
What each file of this folder holds. How a platform checks its files is in
|
||||
[How each platform checks files](../wiki/verification-modes.md), and the
|
||||
steps to add one are in [Adding a platform](../wiki/adding-a-platform.md).
|
||||
|
||||
## Files
|
||||
|
||||
- `_registry.yml` -- platform metadata (name, release pack, display order)
|
||||
- `_shared.yml` -- shared file groups with canonical destinations
|
||||
- `<platform>.yml` -- per-platform BIOS declarations
|
||||
- Inheritance: `lakka.yml` inherits `retroarch`, `retropie.yml` inherits `retroarch`
|
||||
- `<platform>.yml`: the platform's own BIOS list, written by its scraper
|
||||
(`scripts/scraper/<platform>_scraper.py`). A hand edit is overwritten by the
|
||||
next scrape: the fix goes in the scraper, `_shared.yml` or a profile.
|
||||
`lakka.yml` and `retropie.yml` inherit `retroarch`, `romm.yml` inherits
|
||||
`emulatorjs`.
|
||||
- `_registry.yml`: platform metadata (name, scraper, release pack, install
|
||||
detection, display order).
|
||||
- `_shared.yml`: file groups several platforms include, with the destination
|
||||
the core expects.
|
||||
- `_data_dirs.yml`: whole directory trees a core needs.
|
||||
- `_guides.yml`: the guide text of each platform's page on the site.
|
||||
- `_core_info.json`: the git blob of every libretro `.info` as last reviewed,
|
||||
written by `check_freshness.py --record-coreinfo`.
|
||||
- `targets/`: the cores each hardware target runs, one file per platform.
|
||||
- `romfolders/`: the rom folders of each setup.
|
||||
|
||||
## Shared groups (`_shared.yml`)
|
||||
|
||||
The subdirectory a BIOS goes into is determined by the **libretro core**, not
|
||||
the platform. NP2kai expects `np2kai/BIOS.ROM` whether you're on RetroArch,
|
||||
Batocera, or Recalbox. Only `base_destination` varies (`system/` vs `bios/`).
|
||||
The subdirectory a BIOS goes into is set by the core, not the platform.
|
||||
NP2kai expects `np2kai/BIOS.ROM` on RetroArch, Batocera and Recalbox alike.
|
||||
Only `base_destination` varies (`system/` or `bios/`).
|
||||
|
||||
Shared groups define files with correct destinations **once**. Platforms
|
||||
reference them via `includes: [group_name]` in their system definitions.
|
||||
`load_platform_config()` in `scripts/model/platforms.py` resolves includes at load time,
|
||||
deduplicating by filename.
|
||||
A group declares those files and their destination once, and platforms
|
||||
include it with `includes: [group_name]` in a system. `load_platform_config()`
|
||||
(`scripts/model/platforms.py`) resolves the includes at load time. A scraper
|
||||
that writes a platform keeps its includes in its own `SYSTEM_SHARED_GROUPS`,
|
||||
so they survive the next scrape. `libretro_scraper.py` also prefixes the
|
||||
subdirectory of the cores in `CORE_SUBDIR_MAP`.
|
||||
|
||||
When to use shared groups: whenever 2+ platforms share files that a core
|
||||
expects in a specific subdirectory. The group carries the correct destination
|
||||
so platforms can't drift.
|
||||
Adding a group:
|
||||
|
||||
For RetroArch specifically, `libretro_scraper.py` injects `includes:`
|
||||
references and applies subdirectory prefixes via `CORE_SUBDIR_MAP` during
|
||||
generation. Manual edits to `retroarch.yml` will be overwritten on next scrape.
|
||||
1. Add it to `_shared.yml` with a comment citing the code that reads the path.
|
||||
2. Give each file its name, destination with the subdirectory, `required` and
|
||||
hashes.
|
||||
3. Reference it with `includes: [group_name]`, in the scraper's
|
||||
`SYSTEM_SHARED_GROUPS` for a scraped platform.
|
||||
|
||||
## Data directories (`_data_dirs.yml`)
|
||||
|
||||
Some cores need entire directory trees, not just individual BIOS files.
|
||||
Dolphin needs `dolphin-emu/Sys/` (GameSettings, DSP firmware, fonts),
|
||||
PPSSPP needs `PPSSPP/` (font assets, shaders), blueMSX needs `Databases/`
|
||||
and `Machines/` (machine configs).
|
||||
|
||||
These are defined in `_data_dirs.yml` as a central registry with upstream
|
||||
source URLs. The pack generator auto-refreshes from upstream before building
|
||||
(use `--offline` to skip). Data directories live in `data/` (not `bios/`)
|
||||
and are NOT indexed in `database.json`.
|
||||
|
||||
Adding a data directory:
|
||||
1. Add entry to `_data_dirs.yml` with source URL, extraction path, cache location
|
||||
2. Reference via `data_directories: [{ref: key, destination: path}]` in platform systems
|
||||
3. For scraper-generated platforms, add to `SYSTEM_DATA_DIRS` in the scraper
|
||||
4. Run `python scripts/refresh_data_dirs.py --key <name>` to populate the cache
|
||||
|
||||
## Subdirectory reference
|
||||
|
||||
Each entry documents where the requirement comes from. Check these source
|
||||
files to verify or update the paths.
|
||||
Where the subdirectories come from:
|
||||
|
||||
| Core | Subdirectory | Source |
|
||||
|------|-------------|--------|
|
||||
@@ -57,44 +51,36 @@ files to verify or update the paths.
|
||||
| PX68k | `keropi/` | `px68k/libretro/libretro.c` |
|
||||
| QUASI88 | `quasi88/` | `quasi88/src/libretro.c` |
|
||||
| Kronos | `kronos/` | `libretro-kronos/libretro/libretro.c` |
|
||||
| ep128emu | `ep128emu/rom/` | `ep128emu-core/src/libretro.cpp` |
|
||||
| ep128emu | `ep128emu/roms/` | `ep128emu-core/src/libretro.cpp` |
|
||||
| Flycast | `dc/` | `flycast/shell/libretro/libretro.cpp` |
|
||||
| FBNeo NeoCD | `neocd/` | `fbneo/src/burn/drv/neogeo/neo_run.cpp` |
|
||||
| Fuse | `fuse/` | `fuse-libretro/fuse/settings.c` |
|
||||
| hatari | `hatari/tos/` | `hatari/src/tos.c` |
|
||||
|
||||
Full libretro docs: `https://docs.libretro.com/library/<core>/`
|
||||
## Data directories (`_data_dirs.yml`)
|
||||
|
||||
## Adding a platform
|
||||
Some cores need a whole tree: Dolphin's `dolphin-emu/Sys/`, PPSSPP's assets,
|
||||
blueMSX's `Databases/` and `Machines/`. Each entry names its upstream source.
|
||||
`scripts/refresh_data_dirs.py` fetches them into `data/`, which is not indexed
|
||||
in `database.json`, and pack generation refreshes them first unless
|
||||
`--offline` is given.
|
||||
|
||||
1. Create `platforms/<name>.yml`
|
||||
2. Set `base_destination` (`system` or `bios`), `verification_mode`, `hash_type`
|
||||
3. Use `includes: [group]` for systems with subdirectory requirements
|
||||
4. Use `inherits: retroarch` to share RetroArch's file set
|
||||
5. Add platform-specific overrides in `overrides.systems`
|
||||
6. Test: `python scripts/verify.py --platform <name>`
|
||||
Adding a data directory:
|
||||
|
||||
## Adding a shared group
|
||||
1. Add the entry with its source URL, extraction path and cache location.
|
||||
2. Reference it with `data_directories: [{ref: key, destination: path}]` in a
|
||||
platform system, in the scraper's `SYSTEM_DATA_DIRS` for a scraped platform.
|
||||
3. Run `python scripts/refresh_data_dirs.py --key <name>` to fill the cache.
|
||||
|
||||
1. Add the group to `_shared.yml` with a source ref comment
|
||||
2. Include: filename, destination with subdirectory prefix, required flag, hashes
|
||||
3. Reference via `includes: [group_name]` in platform system definitions
|
||||
4. For scraper-generated platforms, add the mapping in the scraper's
|
||||
`SYSTEM_SHARED_GROUPS` dict so it persists across regeneration
|
||||
## Targets (`targets/`)
|
||||
|
||||
## Verification modes
|
||||
`<platform>.yml` lists the cores of each hardware target, written by the
|
||||
platform's target scraper (`scripts/scraper/targets/`), or kept by hand for a
|
||||
single-target platform. `_overrides.yml` is never overwritten: it adds
|
||||
aliases and adds or removes cores per target, `_default` for every target.
|
||||
|
||||
| Platform | Mode | Native logic | Upstream source |
|
||||
|----------|------|-------------|----------------|
|
||||
| RetroArch | existence | `path_is_valid()` -- file exists | `core_info.c` |
|
||||
| Lakka | existence | inherits RetroArch | idem |
|
||||
| RetroPie | existence | inherits RetroArch | idem |
|
||||
| Batocera | md5 | `md5sum()` + `checkInsideZip()` | `batocera-systems` |
|
||||
| RetroBat | md5 | MD5 check via JSON config | `batocera-systems.json` |
|
||||
| EmuDeck | md5 | MD5 whitelist per system | `checkBIOS.sh` |
|
||||
| Recalbox | md5 | multi-hash comma-separated | `es_bios.xml` + `Bios.cpp` |
|
||||
| RetroDECK | md5 | MD5 per file via component manifests | `api_data_processing.sh` |
|
||||
| RomM | md5 | size + any hash (MD5/SHA1/CRC32) | `firmware.py` |
|
||||
| ROCKNIX | md5 | `md5sum()` + `checkInsideZip()` with `altmd5` | `rocknix-systems` |
|
||||
| MiSTer FPGA | md5 | MD5 of the file at its destination | `process_db_index_worker.py` |
|
||||
| BizHawk | sha1 | SHA1 per firmware entry | `FirmwareDatabase.cs` |
|
||||
## Rom folders (`romfolders/`)
|
||||
|
||||
`_sources/<setup>.yml` names the repositories and commits to read and the
|
||||
facts a parser cannot read from a table. `python -m scripts.scraper.romfolders`
|
||||
writes `<setup>.yml` from them, with the folder names the OS itself uses.
|
||||
@@ -30,7 +30,7 @@
|
||||
},
|
||||
"bios_dir": {
|
||||
"type": "string",
|
||||
"description": "Directory the files were scanned from; _mame_clones.json sits beside it."
|
||||
"description": "Directory the files were scanned from. mame_clones.json sits beside it."
|
||||
},
|
||||
"files": {
|
||||
"type": "object",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Merging and writing the MAME clone map _mame_clones.json."""
|
||||
"""Merging and writing the MAME clone map mame_clones.json."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ def database_record(files: dict, indexes: dict, bios_dir: str) -> dict:
|
||||
"generated_at": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
|
||||
"total_files": len(files),
|
||||
"total_size": sum(entry["size"] for entry in files.values()),
|
||||
# The tree these paths belong to: dedup writes _mame_clones.json
|
||||
# The tree these paths belong to: dedup writes mame_clones.json
|
||||
# beside it, and the resolver reads the map there, not at the repo root.
|
||||
"bios_dir": os.path.normpath(bios_dir),
|
||||
"files": files,
|
||||
|
||||
@@ -41,6 +41,18 @@ def json_text(value: object) -> str:
|
||||
return str(value)
|
||||
|
||||
|
||||
def content_differs(
|
||||
path: str, content: str, normalize: Callable[[str], str] | None = None
|
||||
) -> bool:
|
||||
"""Whether path is absent or holds other content once timestamp lines are stripped."""
|
||||
if not os.path.exists(path):
|
||||
return True
|
||||
with open(path) as f:
|
||||
existing = f.read()
|
||||
before, after = (normalize(existing), normalize(content)) if normalize else (existing, content)
|
||||
return _strip_timestamps(before) != _strip_timestamps(after)
|
||||
|
||||
|
||||
def write_if_changed(
|
||||
path: str, content: str, normalize: Callable[[str], str] | None = None
|
||||
) -> bool:
|
||||
@@ -54,16 +66,8 @@ def write_if_changed(
|
||||
part it owns. Without it the second pass always sees a difference, the
|
||||
file is rewritten, and the fresh timestamp defeats the comparison.
|
||||
"""
|
||||
if os.path.exists(path):
|
||||
with open(path) as f:
|
||||
existing = f.read()
|
||||
before, after = (
|
||||
(normalize(existing), normalize(content))
|
||||
if normalize
|
||||
else (existing, content)
|
||||
)
|
||||
if _strip_timestamps(before) == _strip_timestamps(after):
|
||||
return False
|
||||
if not content_differs(path, content, normalize):
|
||||
return False
|
||||
write_text_atomic(path, content)
|
||||
return True
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ Two types of deduplication:
|
||||
2. MAME DEVICE CLONES: Different filenames with identical content in the same
|
||||
MAME directory (e.g., bbc_m87.zip and bbc_24bbc.zip are identical ZIPs).
|
||||
These are NOT aliases: MAME loads each by its unique name. Instead of
|
||||
deleting, we create a _mame_clones.json mapping so generate_pack.py can
|
||||
deleting, we create a mame_clones.json mapping so generate_pack.py can
|
||||
pack all names from a single canonical file.
|
||||
|
||||
After dedup, run generate_db.py --force to rebuild database indexes.
|
||||
|
||||
@@ -40,6 +40,8 @@ STEPS: tuple[Step, ...] = (
|
||||
Step("ruff check .", "the lint rules of pyproject.toml", needs="ruff",
|
||||
provider='pip install -e ".[dev]"'),
|
||||
Step("python scripts/build_installer.py --check", "install.py is the one installer/ builds"),
|
||||
Step("python scripts/generate_readme.py --db database.json --platforms-dir platforms --check",
|
||||
"README.md and CONTRIBUTING.md are the generated ones", env={"RETROBIOS_OFFLINE": "1"}),
|
||||
Step("python scripts/profile_sync.py --added --strict", "each profile the branch adds"),
|
||||
Step("vermin --no-tips -t=3.8- --violations install.py installer", "the installer stays on Python 3.8",
|
||||
needs="vermin", provider="the pip line of CONTRIBUTING.md"),
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
The site served these from other hosts: GitHub avatars and files on the
|
||||
``master`` branch of upstream repositories. A rename upstream broke an image
|
||||
in silence, and every page view hit third-party hosts. This tool copies them
|
||||
into ``docs_assets/logos/`` and ``docs_assets/system-icons/``, which are
|
||||
into ``website/assets/logos/`` and ``website/assets/system-icons/``, which are
|
||||
committed, and records where each came from in a ``sources.json`` beside
|
||||
them. The site build only reads those copies (``sitegen.pageprep.localize_images``).
|
||||
|
||||
|
||||
@@ -18,12 +18,21 @@ sys.path.insert(0, os.path.dirname(__file__))
|
||||
from core.cli import add_repo_inputs
|
||||
from model.database import load_database
|
||||
from core.artifacts import repository_output_lock
|
||||
from sitegen.readme import README_PATH, load_readme_inputs, render_readme, write_readme
|
||||
from sitegen.readme import (
|
||||
README_PATH,
|
||||
check_readme,
|
||||
load_readme_inputs,
|
||||
render_readme,
|
||||
write_readme,
|
||||
)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(allow_abbrev=False, description="Generate slim README.md")
|
||||
add_repo_inputs(parser, "db", "platforms")
|
||||
parser.add_argument("--check", action="store_true",
|
||||
help="exit 1 when README.md or CONTRIBUTING.md differs from what"
|
||||
" the generator writes, writing nothing")
|
||||
args = parser.parse_args()
|
||||
|
||||
import contextlib
|
||||
@@ -38,6 +47,8 @@ def main() -> None:
|
||||
with repository_output_lock(str(README_PATH)), contextlib.ExitStack() as held:
|
||||
hold_data_dirs(held, load_data_dir_registry(args.platforms_dir))
|
||||
inputs = load_readme_inputs(db, args.platforms_dir, args.db)
|
||||
if args.check:
|
||||
sys.exit(check_readme(render_readme(inputs)))
|
||||
write_readme(render_readme(inputs))
|
||||
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ Everything a recording reads is local and the same on every machine:
|
||||
rest of the bootstrap as the site's copy does.
|
||||
- HOME is an empty folder and the prompt is "$ ".
|
||||
|
||||
docs_assets/demo/<stem>.tape drives VHS (github.com/charmbracelet/vhs, with
|
||||
website/assets/demo/<stem>.tape drives VHS (github.com/charmbracelet/vhs, with
|
||||
ttyd, ffmpeg and a Chromium on PATH, and bwrap for the handheld). This
|
||||
script encodes what it records:
|
||||
|
||||
docs_assets/demo/install.gif the README (the default variant only)
|
||||
docs_assets/demo/<stem>.webm the site, with <stem>.mp4 as fallback
|
||||
docs_assets/demo/<stem>.png the first frame shown, the video's poster
|
||||
docs_assets/demo/demo.json per variant, what it shows and its alt text
|
||||
website/assets/demo/install.gif the README (the default variant only)
|
||||
website/assets/demo/<stem>.webm the site, with <stem>.mp4 as fallback
|
||||
website/assets/demo/<stem>.png the first frame shown, the video's poster
|
||||
website/assets/demo/demo.json per variant, what it shows and its alt text
|
||||
|
||||
The site build copies the video files and never runs this script. Run it
|
||||
again when a screen of the installer or the file list of its games changes:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
Each card is an SVG written by ``sitegen.ogcards.og_card_svg`` from the
|
||||
registry, rasterised by a headless Chromium through Playwright, then
|
||||
committed under ``docs_assets/og/``. The site build copies the PNG files and
|
||||
committed under ``website/assets/og/``. The site build copies the PNG files and
|
||||
never runs this script, so it adds nothing to the build's dependencies.
|
||||
Run it again when a section's wording, the platform count, the list of
|
||||
platforms or the consoles of a manufacturer change.
|
||||
|
||||
@@ -11,7 +11,7 @@ four pins per side and the pixel glyph on a 4 by 4 grid. Three variants:
|
||||
shapes rasterised by a headless Chromium through Playwright, for browsers
|
||||
that take no SVG icon and for home-screen shortcuts.
|
||||
|
||||
The files land in ``docs_assets/brand/``, which generate_site.py copies into
|
||||
The files land in ``website/assets/brand/``, which generate_site.py copies into
|
||||
the site. The site build never runs this script.
|
||||
|
||||
The repository's own images come from the same shapes, in ``.github/assets/``:
|
||||
|
||||
@@ -161,7 +161,7 @@ _mame_clone_map_cache: dict[str, dict[str, str]] = {}
|
||||
|
||||
|
||||
class CloneMapUnreadable(SourceUnreadable):
|
||||
"""_mame_clones.json exists but is not a JSON object."""
|
||||
"""mame_clones.json exists but is not a JSON object."""
|
||||
|
||||
|
||||
def clone_map_path(bios_dir: str) -> str:
|
||||
@@ -171,7 +171,7 @@ def clone_map_path(bios_dir: str) -> str:
|
||||
relative to the working directory let a scan of a fixture tree rewrite
|
||||
the repository's own map.
|
||||
"""
|
||||
return os.path.join(os.path.dirname(os.path.abspath(bios_dir)), "_mame_clones.json")
|
||||
return os.path.join(os.path.dirname(os.path.abspath(bios_dir)), "mame_clones.json")
|
||||
|
||||
|
||||
def read_clone_map(clone_path: str) -> dict:
|
||||
@@ -195,7 +195,7 @@ def read_clone_map(clone_path: str) -> dict:
|
||||
def get_mame_clone_map(bios_dir: str | None = None) -> dict[str, str]:
|
||||
"""The MAME clone map (clone_name -> canonical_name) of a scanned tree.
|
||||
|
||||
dedup.py writes _mame_clones.json beside the tree it scanned, and the
|
||||
dedup.py writes mame_clones.json beside the tree it scanned, and the
|
||||
map of one tree says nothing about another: read from the repository
|
||||
root whatever ``--bios-dir`` said, an alternate tree's renamed clones
|
||||
fell out of its packs. Without a tree the repository's own is read.
|
||||
|
||||
@@ -8,7 +8,7 @@ from typing import Any
|
||||
|
||||
from core.paths import REPO_ROOT
|
||||
|
||||
OUT = REPO_ROOT / "docs_assets" / "brand"
|
||||
OUT = REPO_ROOT / "website" / "assets" / "brand"
|
||||
PROJECT = REPO_ROOT / ".github" / "assets"
|
||||
|
||||
HEADER = "#3b3f7a"
|
||||
|
||||
@@ -140,12 +140,12 @@ def _write_public_assets(docs: Path, public: Path) -> None:
|
||||
images_dest = public / "assets" / "images"
|
||||
images_dest.mkdir(parents=True, exist_ok=True)
|
||||
# Logos, system icons and sharing cards are served from the site itself
|
||||
# (docs_assets/*/sources.json records where each came from).
|
||||
# (website/assets/*/sources.json records where each came from).
|
||||
# brand: the mark, favicons and touch icon (scripts/make_site_icons.py).
|
||||
folders = [("logos", "logos"), ("system-icons", "system-icons"), ("og", "og"),
|
||||
("brand", "brand")]
|
||||
for folder, dest in folders:
|
||||
source = Path("docs_assets") / folder
|
||||
source = Path("website", "assets") / folder
|
||||
if source.is_dir():
|
||||
shutil.copytree(source, public / "assets" / dest, dirs_exist_ok=True)
|
||||
# The diagrams and the drawn install steps, one SVG per layout and theme.
|
||||
@@ -154,7 +154,7 @@ def _write_public_assets(docs: Path, public: Path) -> None:
|
||||
demo_dest = public / "assets" / "demo"
|
||||
demo_dest.mkdir(parents=True, exist_ok=True)
|
||||
for name in DEMO_ASSETS:
|
||||
shutil.copy2(Path("docs_assets") / "demo" / name, demo_dest / name)
|
||||
shutil.copy2(Path("website", "assets") / "demo" / name, demo_dest / name)
|
||||
assets_src = Path(".github") / "assets"
|
||||
for name, dest_name in [("logo.png", "logo.png"), ("favicon.png", "favicon.png")]:
|
||||
src = assets_src / name
|
||||
|
||||
@@ -122,7 +122,7 @@ def _coverage_inputs(db_path: Path, platforms_dir: str, emulators_dir: str) -> s
|
||||
revisions = sorted({REPO_ROOT / versions_file_for(entry)
|
||||
for entry in load_data_dir_registry(platforms_dir).values()
|
||||
if entry.get("local_cache")})
|
||||
for path in (REPO_ROOT / ".gitignore", REPO_ROOT / "_mame_clones.json", *revisions):
|
||||
for path in (REPO_ROOT / ".gitignore", REPO_ROOT / "mame_clones.json", *revisions):
|
||||
add_file(path)
|
||||
digest.update(b"offline\0" + (b"1" if run_is_offline() else b"0") + b"\n")
|
||||
large = Path(LARGE_FILES_CACHE).resolve()
|
||||
|
||||
@@ -8,7 +8,7 @@ from pathlib import Path
|
||||
|
||||
from core.paths import REPO_ROOT
|
||||
|
||||
OUT = REPO_ROOT / "docs_assets" / "demo"
|
||||
OUT = REPO_ROOT / "website" / "assets" / "demo"
|
||||
WORK = REPO_ROOT / "tmp" / "demo"
|
||||
FACTS = OUT / "demo.json"
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ def first_screen_words() -> list[str]:
|
||||
f"and **{installer.TUI_FOLDER_TITLE}**), then offers **{installer.TUI_INSTALL_ROW}**."]
|
||||
|
||||
|
||||
# The demo files the site serves (docs_assets/demo/, scripts/make_demo.py):
|
||||
# The demo files the site serves (website/assets/demo/, scripts/make_demo.py):
|
||||
# the GIF is the README's, the tape and demo.json are inputs.
|
||||
DEMO_ASSETS = tuple(f"{stem}.{ext}" for stem in ("install", "install-handheld")
|
||||
for ext in ("webm", "mp4", "png"))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""The platform logos and system icons the site shows, copied once into docs_assets/."""
|
||||
"""The platform logos and system icons the site shows, copied once into website/assets/."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ from model.platforms import load_platform_config
|
||||
from model.registry import list_registered_platforms
|
||||
from sitegen.diagrams import FONT, setups_named, wrap
|
||||
|
||||
OUT = REPO_ROOT / "docs_assets" / "og"
|
||||
LOGO = REPO_ROOT / "docs_assets" / "brand" / "logo.svg"
|
||||
OUT = REPO_ROOT / "website" / "assets" / "og"
|
||||
LOGO = REPO_ROOT / "website" / "assets" / "brand" / "logo.svg"
|
||||
PLATFORM_TAGLINE = "Which BIOS files it needs, and where each one goes"
|
||||
# The tagline's box on the card: og_card_svg wraps it at this width and
|
||||
# size, and three lines fit above the address.
|
||||
@@ -26,7 +26,7 @@ TAGLINE_WIDTH, TAGLINE_SIZE, TAGLINE_LINES = 1000, 34, 3
|
||||
|
||||
|
||||
# Sharing cards: one 1200x630 card per section of the site, rendered to PNG
|
||||
# once by scripts/make_og_cards.py and committed under docs_assets/og/.
|
||||
# once by scripts/make_og_cards.py and committed under website/assets/og/.
|
||||
|
||||
OG_SECTIONS: dict[str, tuple[str, str]] = {
|
||||
"home": ("BIOS and firmware packs", "Checked file by file, for {frontends}"),
|
||||
@@ -40,7 +40,7 @@ OG_SECTIONS: dict[str, tuple[str, str]] = {
|
||||
|
||||
def og_card_svg(section: str, mark_svg: str) -> str:
|
||||
"""A sharing card. ``mark_svg`` is the site's white mark
|
||||
(docs_assets/brand/logo.svg), drawn as the header draws it."""
|
||||
(website/assets/brand/logo.svg), drawn as the header draws it."""
|
||||
title, tagline = OG_SECTIONS[section]
|
||||
tagline = tagline.format(frontends=setups_named(["RetroArch", "Batocera", "EmuDeck"]))
|
||||
mark = mark_svg.strip().replace("<svg ", '<svg x="96" y="88" width="112" height="112" ', 1)
|
||||
|
||||
@@ -46,8 +46,8 @@ def unresolved_images(markdown: str) -> list[str]:
|
||||
|
||||
# Local copies of images the site used to load from other hosts.
|
||||
|
||||
LOGO_DIR = REPO_ROOT / "docs_assets" / "logos"
|
||||
ICON_DIR = REPO_ROOT / "docs_assets" / "system-icons"
|
||||
LOGO_DIR = REPO_ROOT / "website" / "assets" / "logos"
|
||||
ICON_DIR = REPO_ROOT / "website" / "assets" / "system-icons"
|
||||
SITE_LOGO_DIR = "assets/logos"
|
||||
SITE_ICON_DIR = "assets/system-icons"
|
||||
IMAGE_LINK = re.compile(r"(!\[[^\]\n]*\]\()(https?://[^)\s]+)(\))")
|
||||
|
||||
@@ -14,7 +14,7 @@ from core.text import series
|
||||
from romrecipes import ledger
|
||||
from devtools import prchecks
|
||||
from model import releaserecord, siteinputs
|
||||
from core.artifacts import write_if_changed
|
||||
from core.artifacts import content_differs, write_if_changed
|
||||
from core.paths import DB_FILE, REPO_ROOT
|
||||
from core.sizes import size_text
|
||||
from core import upstream
|
||||
@@ -94,7 +94,7 @@ def collection_line(total_files: int, comp: dict) -> str:
|
||||
|
||||
|
||||
# The installer demo (scripts/make_demo.py): the recording and what it shows.
|
||||
DEMO_GIF = "docs_assets/demo/install.gif"
|
||||
DEMO_GIF = "website/assets/demo/install.gif"
|
||||
REPO = REPO_SLUG
|
||||
README_PATH = REPO_ROOT / "README.md"
|
||||
CONTRIBUTING_PATH = REPO_ROOT / "CONTRIBUTING.md"
|
||||
@@ -372,6 +372,7 @@ def render_readme(inputs: ReadmeInputs) -> str:
|
||||
f"- Have a file? [Check it by its hash]({SITE_URL}files/)",
|
||||
f"- Every console and the files it needs: [systems]({SITE_URL}systems/)",
|
||||
f"- Asking an AI assistant: it reads the site best from [llms.txt]({SITE_URL}llms.txt)",
|
||||
f"- Screen reader, keyboard only or no colour: [accessibility]({SITE_URL}wiki/accessibility/)",
|
||||
"",
|
||||
"## How it is built",
|
||||
"",
|
||||
@@ -612,14 +613,32 @@ def generate_contributing() -> str:
|
||||
)
|
||||
|
||||
|
||||
def write_readme(readme: str) -> None:
|
||||
status = "Generated" if write_if_changed(str(README_PATH), readme) else "Unchanged"
|
||||
print(f"{status} ./README.md")
|
||||
# The first line of both repository files: GitHub renders the comment as
|
||||
# nothing, and whoever opens the file to edit it learns where the text comes from.
|
||||
GENERATED_MARKER = (
|
||||
"<!-- Generated by scripts/generate_readme.py from scripts/sitegen/readme.py."
|
||||
" Edit the generator, then run it: a hand edit fails the Validation workflow. -->\n"
|
||||
)
|
||||
|
||||
contributing = generate_contributing()
|
||||
status = (
|
||||
"Generated"
|
||||
if write_if_changed(str(CONTRIBUTING_PATH), contributing)
|
||||
else "Unchanged"
|
||||
)
|
||||
print(f"{status} ./CONTRIBUTING.md")
|
||||
|
||||
def readme_files(readme: str) -> dict[Path, str]:
|
||||
"""README.md and CONTRIBUTING.md as the repository holds them."""
|
||||
return {
|
||||
Path(README_PATH): GENERATED_MARKER + readme,
|
||||
Path(CONTRIBUTING_PATH): GENERATED_MARKER + generate_contributing(),
|
||||
}
|
||||
|
||||
|
||||
def check_readme(readme: str) -> int:
|
||||
"""1, naming each file, when the committed text differs from the generated one."""
|
||||
stale = [path.name for path, text in readme_files(readme).items()
|
||||
if content_differs(str(path), text)]
|
||||
for name in stale:
|
||||
print(f"{name} differs from what generate_readme.py writes: run it and commit")
|
||||
return 1 if stale else 0
|
||||
|
||||
|
||||
def write_readme(readme: str) -> None:
|
||||
for path, text in readme_files(readme).items():
|
||||
status = "Generated" if write_if_changed(str(path), text) else "Unchanged"
|
||||
print(f"{status} ./{path.name}")
|
||||
@@ -64,7 +64,7 @@ def prime_system_icons(names: set[str]) -> int:
|
||||
"""Record which system icons the site holds a copy of, and return how
|
||||
many of ``names`` have none.
|
||||
|
||||
The icons are copied once into ``docs_assets/system-icons/`` by
|
||||
The icons are copied once into ``website/assets/system-icons/`` by
|
||||
``scripts/fetch_site_images.py``: the build reads that folder and never
|
||||
the network. A system without a copy gets no icon, because a heading
|
||||
with a broken image reads worse than a heading without one.
|
||||
|
||||
@@ -315,7 +315,7 @@ def og_section(rel: str, level: str) -> str:
|
||||
|
||||
# Sharing cards of their own, made by scripts/make_og_cards.py: one per
|
||||
# platform page, titled with the platform's name.
|
||||
OG_DIR = REPO_ROOT / "docs_assets" / "og"
|
||||
OG_DIR = REPO_ROOT / "website" / "assets" / "og"
|
||||
|
||||
|
||||
# An emulator page's card is that of the maker of the first system it runs,
|
||||
|
||||
@@ -86,7 +86,7 @@ STEPS: dict[str, tuple[str, tuple[Step, ...]]] = {
|
||||
)),
|
||||
}
|
||||
|
||||
# The recording each tab shows (docs_assets/demo/demo.json keys), "" for none.
|
||||
# The recording each tab shows (website/assets/demo/demo.json keys), "" for none.
|
||||
TAB_DEMOS = {"device": "handheld", "windows": ""}
|
||||
DEFAULT_DEMO = "default"
|
||||
|
||||
|
||||
@@ -800,7 +800,7 @@ class DocsDescribeTheRegistriesTheyName(unittest.TestCase):
|
||||
tools = (REPO_ROOT / "wiki" / "tools.md").read_text(encoding="utf-8")
|
||||
line = next(entry for entry in tools.splitlines() if "NODEDUP_DIRS" in entry)
|
||||
# Compared as list items: `mame` was missing while the substring
|
||||
# test found it in `_mame_clones.json` on the same line.
|
||||
# test found it in `mame_clones.json` on the same line.
|
||||
listed = line.split("`NODEDUP_DIRS`", 1)[1].split(":", 1)[1].rstrip(" |")
|
||||
self.assertEqual(
|
||||
sorted(item.strip() for item in listed.split(",")),
|
||||
|
||||
@@ -550,7 +550,7 @@ class GeneratedModelsAreWrittenWhole(unittest.TestCase):
|
||||
archive.writestr("rom.bin", b"rom")
|
||||
data = (bios / "Arcade" / "MAME" / "set.zip").read_bytes()
|
||||
(bios / "Arcade" / "MAME" / "setclone.zip").write_bytes(data)
|
||||
(root / "_mame_clones.json").write_text("<<<<<<< HEAD")
|
||||
(root / "mame_clones.json").write_text("<<<<<<< HEAD")
|
||||
from model.database import CloneMapUnreadable
|
||||
|
||||
with self.assertRaises(CloneMapUnreadable):
|
||||
@@ -564,11 +564,11 @@ class GeneratedModelsAreWrittenWhole(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
(root / "bios").mkdir()
|
||||
(root / "_mame_clones.json").write_text("<<<<<<< HEAD")
|
||||
(root / "mame_clones.json").write_text("<<<<<<< HEAD")
|
||||
with self.assertRaises(database.CloneMapUnreadable) as caught:
|
||||
database.get_mame_clone_map(str(root / "bios"))
|
||||
self.assertIn("Restore it from git", str(caught.exception))
|
||||
(root / "_mame_clones.json").write_text("[]")
|
||||
(root / "mame_clones.json").write_text("[]")
|
||||
with self.assertRaises(database.CloneMapUnreadable):
|
||||
database.get_mame_clone_map(str(root / "bios"))
|
||||
|
||||
@@ -765,7 +765,7 @@ class AMameCloneNameIsANameStep(unittest.TestCase):
|
||||
bios.mkdir(parents=True)
|
||||
parent = bios / "parent.zip"
|
||||
parent.write_bytes(b"PARENTSET")
|
||||
(self.tmp / "_mame_clones.json").write_text(
|
||||
(self.tmp / "mame_clones.json").write_text(
|
||||
json.dumps({"parent.zip": {"clones": ["clone.zip"]}})
|
||||
)
|
||||
sha1 = hashlib.sha1(parent.read_bytes()).hexdigest()
|
||||
|
||||
@@ -248,7 +248,7 @@ class CloneMapSurvivesASecondRun(_Bios):
|
||||
def _map(self) -> dict:
|
||||
import json
|
||||
|
||||
path = Path(self._tmp.name) / "_mame_clones.json"
|
||||
path = Path(self._tmp.name) / "mame_clones.json"
|
||||
return json.loads(path.read_text()) if path.exists() else {}
|
||||
|
||||
def test_the_map_is_written_beside_the_scanned_tree_not_the_cwd(self):
|
||||
@@ -256,7 +256,7 @@ class CloneMapSurvivesASecondRun(_Bios):
|
||||
|
||||
The map was written to the working directory. The test suite runs
|
||||
from the repo root, so a fixture scan of a temporary tree rewrote the
|
||||
committed _mame_clones.json with two fixture entries, and a later
|
||||
committed mame_clones.json with two fixture entries, and a later
|
||||
rewrite left 2 of its 71 parents.
|
||||
"""
|
||||
elsewhere = Path(self._tmp.name) / "elsewhere"
|
||||
@@ -265,7 +265,7 @@ class CloneMapSurvivesASecondRun(_Bios):
|
||||
self.write("Arcade/MAME/bbc_m87.zip")
|
||||
self.write("Arcade/MAME/bbc_24bbc.zip")
|
||||
self.run_dedup()
|
||||
self.assertFalse((elsewhere / "_mame_clones.json").exists())
|
||||
self.assertFalse((elsewhere / "mame_clones.json").exists())
|
||||
self.assertIn("bbc_m87.zip", self._map())
|
||||
|
||||
def test_a_recorded_mapping_survives_a_later_run(self):
|
||||
|
||||
@@ -189,7 +189,7 @@ CONTRIBUTOR_PAGES = (
|
||||
REPO_DIRS = (
|
||||
"scripts/", "platforms/", "emulators/", "schemas/", "tests/", "wiki/", "install/",
|
||||
"provenance/", "recipes/", "exports/", "measurements/", "website/", "automation/",
|
||||
"ports/", "docs_assets/", "docs/", "campaign/",
|
||||
"ports/", "docs/", "campaign/",
|
||||
)
|
||||
|
||||
PLACEHOLDER = re.compile(r"[<>*{}]|myplatform|\bNAME\b|\.\.\.")
|
||||
|
||||
@@ -62,7 +62,7 @@ class SuiteWithoutJsonschema(unittest.TestCase):
|
||||
|
||||
|
||||
# Tools a maintainer runs by hand when a logo or a card changes. Their output
|
||||
# is committed under docs_assets/ and the build only reads it, so the build
|
||||
# is committed under website/assets/ and the build only reads it, so the build
|
||||
# keeps to the standard library and pyyaml.
|
||||
MAINTENANCE_TOOLS = {
|
||||
"sitegen/imagenormalize.py": "PIL",
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
"""The repository's root says what each of its entries is and which files are generated.
|
||||
|
||||
The directory map of the architecture page left out games/, packaging/,
|
||||
measurements/ and four root data files, and README.md and CONTRIBUTING.md
|
||||
gave no sign that a generator writes them.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from core.generated import GENERATED
|
||||
from sitegen.readme import GENERATED_MARKER
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
# Named by the map, never tracked: written by a run.
|
||||
UNTRACKED = {"data/", "dist/", ".cache/"}
|
||||
|
||||
|
||||
def _tracked_root() -> set[str]:
|
||||
listed = subprocess.run(
|
||||
["git", "ls-files", "-z"], cwd=REPO_ROOT, capture_output=True, check=True,
|
||||
).stdout.decode("utf-8").split("\0")
|
||||
return {
|
||||
path.split("/", 1)[0] + ("/" if "/" in path else "")
|
||||
for path in listed if path
|
||||
}
|
||||
|
||||
|
||||
def _map_block() -> str:
|
||||
page = (REPO_ROOT / "wiki" / "architecture.md").read_text(encoding="utf-8")
|
||||
section = page.split("## Directory structure", 1)[1]
|
||||
return section.split("```", 2)[1]
|
||||
|
||||
|
||||
class TheMapNamesEveryRootEntry(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
if not (REPO_ROOT / ".git").exists():
|
||||
self.skipTest("not a git checkout")
|
||||
|
||||
def test_every_tracked_root_entry_is_in_the_map(self):
|
||||
names = set(re.findall(r"[\w.-]+/?", _map_block()))
|
||||
self.assertEqual(sorted(_tracked_root() - names), [])
|
||||
|
||||
def test_every_root_entry_of_the_map_exists(self):
|
||||
named = {word.split("/", 1)[0] + ("/" if "/" in word else "")
|
||||
for word in (line.split()[0] for line in _map_block().splitlines()
|
||||
if line and not line[0].isspace())}
|
||||
self.assertEqual(sorted(named - _tracked_root() - UNTRACKED), [])
|
||||
|
||||
|
||||
class GeneratedFilesAreMarked(unittest.TestCase):
|
||||
def test_gitattributes_marks_what_a_pipeline_run_writes(self):
|
||||
text = (REPO_ROOT / ".gitattributes").read_text(encoding="utf-8")
|
||||
marked = re.findall(r"(?m)^/(\S+)\s+linguist-generated=true$", text)
|
||||
self.assertEqual(marked, list(GENERATED))
|
||||
|
||||
def test_readme_and_contributing_name_their_generator(self):
|
||||
for name in ("README.md", "CONTRIBUTING.md"):
|
||||
with self.subTest(file=name):
|
||||
text = (REPO_ROOT / name).read_text(encoding="utf-8")
|
||||
self.assertTrue(text.startswith(GENERATED_MARKER))
|
||||
|
||||
def test_a_hand_edit_fails_validation(self):
|
||||
workflow = yaml.safe_load(
|
||||
(REPO_ROOT / ".github" / "workflows" / "validate.yml").read_text(encoding="utf-8"))
|
||||
on = workflow.get("on", workflow.get(True))
|
||||
for event in ("pull_request", "push"):
|
||||
with self.subTest(event=event):
|
||||
self.assertLessEqual({"README.md", "CONTRIBUTING.md"}, set(on[event]["paths"]))
|
||||
runs = [str(step.get("run", "")) for job in workflow["jobs"].values()
|
||||
for step in job["steps"]]
|
||||
self.assertIn(
|
||||
"python scripts/generate_readme.py --db database.json --platforms-dir platforms --check",
|
||||
runs)
|
||||
|
||||
def test_the_check_names_a_hand_edit(self):
|
||||
import io
|
||||
from contextlib import redirect_stdout
|
||||
from tempfile import TemporaryDirectory
|
||||
from unittest import mock
|
||||
|
||||
from sitegen import readme
|
||||
|
||||
with TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
paths = {"README_PATH": root / "README.md", "CONTRIBUTING_PATH": root / "CONTRIBUTING.md"}
|
||||
with mock.patch.multiple(readme, **paths):
|
||||
with redirect_stdout(io.StringIO()):
|
||||
readme.write_readme("body\n")
|
||||
out = io.StringIO()
|
||||
with redirect_stdout(out):
|
||||
self.assertEqual(readme.check_readme("body\n"), 0)
|
||||
paths["README_PATH"].write_text(GENERATED_MARKER + "edited\n", encoding="utf-8")
|
||||
with redirect_stdout(out):
|
||||
self.assertEqual(readme.check_readme("body\n"), 1)
|
||||
self.assertIn("README.md differs", out.getvalue())
|
||||
self.assertNotIn("CONTRIBUTING.md differs", out.getvalue())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -302,7 +302,7 @@ class Picker(unittest.TestCase):
|
||||
|
||||
|
||||
UNBROKEN = WEBSITE / "src" / "plugins" / "ec-unbroken-tokens.mjs"
|
||||
LOGOS = REPO_ROOT / "docs_assets" / "logos"
|
||||
LOGOS = REPO_ROOT / "website" / "assets" / "logos"
|
||||
|
||||
# Shown at 40 px in a tile and beside a setup's title: twice that for a
|
||||
# sharp mark on a dense screen.
|
||||
|
||||
@@ -28,7 +28,7 @@ from sitegen import starlight as sitestarlight
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
DEMO = ROOT / "docs_assets" / "demo"
|
||||
DEMO = ROOT / "website" / "assets" / "demo"
|
||||
COMPONENT = ROOT / "website" / "src" / "components" / "InstallDemo.astro"
|
||||
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ class NoMermaidAtRuntime(unittest.TestCase):
|
||||
|
||||
class ImagesAreServedFromTheSite(unittest.TestCase):
|
||||
def _manifest(self, folder: str) -> list[dict]:
|
||||
path = ROOT / "docs_assets" / folder / "sources.json"
|
||||
path = ROOT / "website" / "assets" / folder / "sources.json"
|
||||
return json.loads(path.read_text(encoding="utf-8"))["images"]
|
||||
|
||||
def test_every_registry_logo_has_a_local_copy(self):
|
||||
@@ -155,13 +155,13 @@ class ImagesAreServedFromTheSite(unittest.TestCase):
|
||||
with self.subTest(platform=name):
|
||||
self.assertIn(name, copies, "run scripts/fetch_site_images.py --only logos")
|
||||
self.assertEqual(copies[name]["source"], entry["logo"])
|
||||
self.assertTrue((ROOT / "docs_assets" / "logos" / copies[name]["file"]).is_file())
|
||||
self.assertTrue((ROOT / "website" / "assets" / "logos" / copies[name]["file"]).is_file())
|
||||
self.assertTrue(copies[name]["owner"] and copies[name]["licence"])
|
||||
|
||||
def test_every_recorded_icon_exists(self):
|
||||
for entry in self._manifest("system-icons"):
|
||||
with self.subTest(icon=entry["file"]):
|
||||
self.assertTrue((ROOT / "docs_assets" / "system-icons" / entry["file"]).is_file())
|
||||
self.assertTrue((ROOT / "website" / "assets" / "system-icons" / entry["file"]).is_file())
|
||||
|
||||
def test_remote_links_with_a_copy_are_rewritten(self):
|
||||
logo = self._manifest("logos")[0]
|
||||
@@ -195,10 +195,10 @@ class SharingCards(unittest.TestCase):
|
||||
|
||||
for section in ogcards.OG_SECTIONS:
|
||||
with self.subTest(section=section):
|
||||
data = (ROOT / "docs_assets" / "og" / f"{section}.png").read_bytes()
|
||||
data = (ROOT / "website" / "assets" / "og" / f"{section}.png").read_bytes()
|
||||
self.assertEqual(data[:8], b"\x89PNG\r\n\x1a\n")
|
||||
self.assertEqual(struct.unpack(">II", data[16:24]), (1200, 630))
|
||||
mark = (ROOT / "docs_assets" / "brand" / "logo.svg").read_text(encoding="utf-8")
|
||||
mark = (ROOT / "website" / "assets" / "brand" / "logo.svg").read_text(encoding="utf-8")
|
||||
ET.fromstring(ogcards.og_card_svg(section, mark))
|
||||
|
||||
def test_the_template_names_every_section(self):
|
||||
@@ -210,14 +210,14 @@ class SharingCards(unittest.TestCase):
|
||||
self.assertEqual(named, set(ogcards.OG_SECTIONS))
|
||||
for section in named:
|
||||
with self.subTest(section=section):
|
||||
self.assertTrue((ROOT / "docs_assets" / "og" / f"{section}.png").is_file())
|
||||
self.assertTrue((ROOT / "website" / "assets" / "og" / f"{section}.png").is_file())
|
||||
|
||||
|
||||
class ImagesStillNeeded(unittest.TestCase):
|
||||
"""Screens that need a real device are listed, never drawn as a mock-up."""
|
||||
|
||||
def test_the_list_gives_each_capture_its_alt_text(self):
|
||||
text = (ROOT / "docs_assets" / "images-needed.md").read_text(encoding="utf-8")
|
||||
text = (ROOT / "wiki" / "images-wanted.md").read_text(encoding="utf-8")
|
||||
entries = re.findall(r"(?m)^## ", text)
|
||||
self.assertGreater(len(entries), 3)
|
||||
self.assertEqual(len(entries), len(re.findall(r"(?m)^\*\*Alt text\*\*", text)))
|
||||
|
||||
@@ -92,7 +92,7 @@ class PlatformLogos(unittest.TestCase):
|
||||
|
||||
tiles = {re.sub(r"[^a-z0-9]+", "-", tile.name.lower()).strip("-"): tile.logo
|
||||
for group in group_tiles().values() for tile in group}
|
||||
sources = json.loads((REPO_ROOT / "docs_assets" / "logos" / "sources.json").read_text())
|
||||
sources = json.loads((REPO_ROOT / "website" / "assets" / "logos" / "sources.json").read_text())
|
||||
for entry in sources["images"]:
|
||||
with self.subTest(platform=entry["platform"]):
|
||||
logo = (self.registry[entry["platform"]].get("logo")
|
||||
|
||||
@@ -285,7 +285,7 @@ class PlatformShareCards(unittest.TestCase):
|
||||
def test_every_platform_page_shares_its_own_card(self):
|
||||
for key in list_registered_platforms(str(REPO_ROOT / "platforms")):
|
||||
with self.subTest(platform=key):
|
||||
card = REPO_ROOT / "docs_assets" / "og" / "platforms" / f"{key}.png"
|
||||
card = REPO_ROOT / "website" / "assets" / "og" / "platforms" / f"{key}.png"
|
||||
data = card.read_bytes()
|
||||
self.assertEqual(struct.unpack(">II", data[16:24]), (1200, 630))
|
||||
self.assertEqual(sitestarlight.og_image(f"platforms/{key}.md", "setup"),
|
||||
|
||||
@@ -26,7 +26,7 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
class IconsComeFromTheLocalCopies(unittest.TestCase):
|
||||
"""Icons were checked against upstream with a HEAD request per system on
|
||||
every build, and linked from a branch tip. The build now reads the copies
|
||||
in docs_assets/system-icons and makes no request."""
|
||||
in website/assets/system-icons and makes no request."""
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.addCleanup(runlinks.use, runlinks.current())
|
||||
@@ -35,7 +35,7 @@ class IconsComeFromTheLocalCopies(unittest.TestCase):
|
||||
def test_availability_is_the_folder(self):
|
||||
tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(tmp.cleanup)
|
||||
folder = Path(tmp.name) / "docs_assets" / "system-icons"
|
||||
folder = Path(tmp.name) / "website" / "assets" / "system-icons"
|
||||
folder.mkdir(parents=True)
|
||||
(folder / "A - One.png").write_bytes(b"png")
|
||||
with mock.patch.object(runlinks, "ICON_DIR", folder):
|
||||
|
||||
@@ -598,10 +598,10 @@ class EachManufacturerHasItsCard(unittest.TestCase):
|
||||
def test_every_manufacturer_page_has_a_committed_card(self) -> None:
|
||||
cards = ogcards.system_cards()
|
||||
missing = [key for key in cards
|
||||
if not (REPO_ROOT / "docs_assets" / "og" / f"{key}.png").is_file()]
|
||||
if not (REPO_ROOT / "website" / "assets" / "og" / f"{key}.png").is_file()]
|
||||
self.assertEqual(missing, [], "run python scripts/make_og_cards.py --only systems")
|
||||
# A card left behind by a page that went: oric.png outlived its page.
|
||||
committed = (REPO_ROOT / "docs_assets" / "og" / "systems").glob("*.png")
|
||||
committed = (REPO_ROOT / "website" / "assets" / "og" / "systems").glob("*.png")
|
||||
stale = sorted(f"systems/{path.stem}" for path in committed
|
||||
if f"systems/{path.stem}" not in cards)
|
||||
self.assertEqual(stale, [])
|
||||
|
||||
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 99 KiB |
|
Before Width: | Height: | Size: 218 KiB After Width: | Height: | Size: 218 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 788 B After Width: | Height: | Size: 788 B |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 314 B After Width: | Height: | Size: 314 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 828 B After Width: | Height: | Size: 828 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 917 B After Width: | Height: | Size: 917 B |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |