mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
refactor: read the demo facts in demovariants
This commit is contained in:
1 parent
416299b6e0
commit
9a6003c22f
5 files changed
+19
-18
No files matched your search
@@ -144,6 +144,7 @@ on:
|
||||
- "scripts/sitegen/dataexports.py"
|
||||
- "scripts/sitegen/datapage.py"
|
||||
- "scripts/sitegen/decorate.py"
|
||||
- "scripts/sitegen/demovariants.py"
|
||||
- "scripts/sitegen/descriptions.py"
|
||||
- "scripts/sitegen/diagrams.py"
|
||||
- "scripts/sitegen/emulatorcards.py"
|
||||
|
||||
@@ -101,6 +101,19 @@ def load_facts() -> dict:
|
||||
return json.loads(FACTS.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def demo_facts(variant: str = "default") -> dict:
|
||||
"""What an installer demo shows, as make_demo.py measured it: one entry
|
||||
per variant (default, handheld)."""
|
||||
facts = json.loads(FACTS.read_text(encoding="utf-8"))
|
||||
return facts[variant]
|
||||
|
||||
|
||||
def demo_description(facts: dict | None = None) -> str:
|
||||
"""The demo in words, for a reader who cannot see it: the alt text
|
||||
make_demo.py wrote from what it measured."""
|
||||
return str((facts or demo_facts())["alt"])
|
||||
|
||||
|
||||
def write_facts(facts: dict) -> None:
|
||||
"""demo.json, one entry per variant recorded so far, in VARIANTS order."""
|
||||
ordered = {name: facts[name] for name in VARIANTS if name in facts}
|
||||
|
||||
@@ -12,7 +12,7 @@ from model.profiles import unique_emulator_profiles
|
||||
from model.registry import load_platform_registry
|
||||
from sitegen import markup
|
||||
from sitegen.install import platform_display
|
||||
from sitegen.readme import demo_description, demo_facts
|
||||
from sitegen.demovariants import demo_description, demo_facts
|
||||
|
||||
|
||||
# Home page
|
||||
|
||||
@@ -27,6 +27,7 @@ from model.systems import system_index
|
||||
from resolve.review import LARGE_FILE_ISSUE_URL
|
||||
from sitegen.config import REPO_SLUG, REPO_URL, SITE_URL, UPLOAD_ROOT
|
||||
from sitegen.coverage import platform_coverages
|
||||
from sitegen.demovariants import demo_description
|
||||
from sitegen.extraction import extract_targets
|
||||
from sitegen.releasepacks import download_links, release_totals
|
||||
|
||||
@@ -91,7 +92,6 @@ def collection_line(total_files: int, comp: dict) -> str:
|
||||
|
||||
|
||||
# The installer demo (scripts/make_demo.py): the recording and what it shows.
|
||||
DEMO_DIR = REPO_ROOT / "docs_assets" / "demo"
|
||||
DEMO_GIF = "docs_assets/demo/install.gif"
|
||||
REPO_PATH = "../.."
|
||||
REPO = REPO_SLUG
|
||||
@@ -123,19 +123,6 @@ def clone_line(db: dict) -> str:
|
||||
)
|
||||
|
||||
|
||||
def demo_facts(variant: str = "default") -> dict:
|
||||
"""What an installer demo shows, as make_demo.py measured it: one entry
|
||||
per variant (default, handheld)."""
|
||||
facts = json.loads((DEMO_DIR / "demo.json").read_text(encoding="utf-8"))
|
||||
return facts[variant]
|
||||
|
||||
|
||||
def demo_description(facts: dict | None = None) -> str:
|
||||
"""The demo in words, for a reader who cannot see it: the alt text
|
||||
make_demo.py wrote from what it measured."""
|
||||
return str((facts or demo_facts())["alt"])
|
||||
|
||||
|
||||
def _existing_contributor_block(readme_path: str = "README.md") -> list[str]:
|
||||
"""The contributors already published, read back from the file.
|
||||
|
||||
|
||||
@@ -132,14 +132,14 @@ class TheTapeAndTheDriverAgree(unittest.TestCase):
|
||||
class TheReadmeShowsTheGif(unittest.TestCase):
|
||||
def test_the_gif_sits_under_the_commands_with_its_description(self):
|
||||
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
||||
line = f""
|
||||
line = f""
|
||||
self.assertIn(line, readme)
|
||||
self.assertLess(readme.index("## Install in one line"), readme.index(line))
|
||||
self.assertLess(readme.index(line), readme.index("## Or download a ZIP"))
|
||||
|
||||
def test_the_description_names_what_the_recording_measured(self):
|
||||
facts = _facts()
|
||||
words = sitegen_readme.demo_description(facts)
|
||||
words = demovariants.demo_description(facts)
|
||||
for value in (facts["setup"], f"{facts['games']} games", f"{facts['files']} BIOS files",
|
||||
facts["size"]):
|
||||
self.assertIn(str(value), words)
|
||||
@@ -197,7 +197,7 @@ class TheTwoPagesShowIt(unittest.TestCase):
|
||||
from sitegen import home
|
||||
|
||||
tag = home.install_demo()[0]
|
||||
self.assertIn(f'description="{sitegen_readme.demo_description()}"', tag)
|
||||
self.assertIn(f'description="{demovariants.demo_description()}"', tag)
|
||||
source = script_source("generate_site.py")
|
||||
body = source[source.index("def generate_home("):]
|
||||
body = body[:body.index("\ndef ", 1)]
|
||||
|
||||
Reference in new issue
Block a user