From b48201547f192d3534a6ca9aabe380bf0d733416 Mon Sep 17 00:00:00 2001 From: arios4k Date: Mon, 23 Nov 2026 12:26:20 -0800 Subject: [PATCH] Bust cached manual screenshot URLs Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- docs/manual/build.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/manual/build.py b/docs/manual/build.py index bbbdf34..b8edefa 100644 --- a/docs/manual/build.py +++ b/docs/manual/build.py @@ -9,7 +9,7 @@ callouts, **bold**, *italic*, `code`, [links](url), , and `![alt](shot:NAME)` for a light/dark pair of screenshots from docs/screenshots. """ -import html, json, re, shutil, sys +import hashlib, html, json, re, shutil, sys from pathlib import Path HERE = Path(__file__).resolve().parent @@ -48,10 +48,20 @@ def link(url): return url if url.endswith(".html") else url + ".html" +def screenshot_url(name, theme): + path = SHOTS / f"{name}-{theme}.png" + if not path.is_file(): + sys.exit(f"missing screenshot: {path}") + version = hashlib.sha256(path.read_bytes()).hexdigest()[:12] + return f"img/{name}-{theme}.png?v={version}" + + def picture(alt, name): a = html.escape(alt, quote=True) - return (f'
' - f'{a}' + dark = screenshot_url(name, "dark") + light = screenshot_url(name, "light") + return (f'
' + f'{a}' f"
{html.escape(alt)}
") @@ -244,7 +254,10 @@ def nav(current): bad.append(f'{p["stem"]}: no page {href}') elif frag and target in ids and frag not in ids[target]: bad.append(f'{p["stem"]}: no section {href}') - bad += [f'{p["stem"]}: missing {src}' for src in re.findall(r'src="([^"]+)"', text) if not (out / src).exists()] + for src in re.findall(r'(?:src|srcset)="([^"]+)"', text): + path = src.partition("?")[0] + if not (out / path).exists(): + bad.append(f'{p["stem"]}: missing {src}') if bad: sys.exit("Broken links in the manual:\n " + "\n ".join(bad)) print(f"Manual: {len(pages)} pages, {len(used_shots)} screenshots -> {out}")