diff --git a/scripts/generate_site.py b/scripts/generate_site.py
index 8272392a7..e1428de88 100644
--- a/scripts/generate_site.py
+++ b/scripts/generate_site.py
@@ -95,6 +95,7 @@ import siteentries
import siteinputs
import retired_files
import siteagents
+import sitediagrams
import sitestarlight
import sitesteps
from siteexports import generate_exports_page, load_export_reports
@@ -12497,6 +12498,9 @@ def _generate(args: argparse.Namespace) -> None:
source = Path("docs_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.
+ sitediagrams.write_diagram_files(public / sitediagrams.DIAGRAM_DIR,
+ {**sitediagrams.figure_files(), **sitesteps.steps_files()})
demo_dest = public / "assets" / "demo"
demo_dest.mkdir(parents=True, exist_ok=True)
for name in DEMO_ASSETS:
diff --git a/scripts/sitediagrams.py b/scripts/sitediagrams.py
index 09e78ddfd..aa192d101 100644
--- a/scripts/sitediagrams.py
+++ b/scripts/sitediagrams.py
@@ -9,14 +9,20 @@ A page asks for a diagram with an HTML comment on a line of its own::
-``resolve_images`` replaces the comment with the figure. The SVG is inline
-so its text takes the page font and its colours come from the theme
-variables in ``docs_assets/extra.css``: it follows the palette toggle, which
-an ```` cannot. Presentation attributes give the same drawing a
-readable default when the SVG is opened on its own.
+``resolve_images`` replaces the comment with the figure. Each drawing is
+an SVG file shown through ````, so the page text holds its words once:
+an inline SVG put every label of both layouts, its title and its desc into
+what a screen reader, a copy, a text dump or a crawler reads, next to the
+prose that already says them. A file reads no stylesheet of the page, so it
+is written once per theme with the colours retrobios.css gives the
+``rb-d-*`` classes (``THEMES``), and the stylesheet shows the one of the
+current theme. Presentation attributes give the same drawing a readable
+default when the SVG is opened on its own.
-Every figure carries two layouts, wide and narrow, and the stylesheet shows
-one: a 720-unit drawing scaled to a phone would print 9 px text.
+Every figure carries two layouts, wide and narrow, and ```` picks
+one: a 720-unit drawing scaled to a phone would print 9 px text. The
+drawings are ``alt=""``: the figure says what they show once, in a
+screen-reader line, and the caption under them.
"""
from __future__ import annotations
@@ -296,22 +302,112 @@ def grid(boxes: list[Box], per_row: int, total: float) -> tuple[float, float, li
return total, y - gap_y + 1, out
-def svg(figure: Figure, layout: str, suffix: str) -> str:
- """One layout of *figure* as a standalone, accessible SVG element."""
- width, height, body = (figure.wide if layout == "wide" else figure.narrow)()
- base = f"rb-fig-{figure.image_id}{suffix}-{layout}"
+def svg_document(width: float, height: float, title: str, desc: str, body: list[str],
+ base: str) -> str:
+ """A drawing as a standalone, accessible SVG element."""
return (
f'"
)
+def svg(figure: Figure, layout: str, suffix: str = "") -> str:
+ """One layout of *figure* as a standalone, accessible SVG element."""
+ width, height, body = (figure.wide if layout == "wide" else figure.narrow)()
+ return svg_document(width, height, figure.title, figure.desc, body,
+ f"rb-fig-{figure.image_id}{suffix}-{layout}")
+
+
+# The colours retrobios.css gives a diagram, per theme: --rb-diagram-* and
+# --rb-text-secondary, then the text and background Starlight resolves
+# --sl-color-text and --sl-color-bg to (props.css: gray-2 and black, whose
+# values swap with the theme). An SVG shown through reads none of them.
+THEMES: dict[str, dict[str, str]] = {
+ "dark": {"text": "#c1c3c8", "bg": "#17181c", "fill": "#252838", "stroke": "#7c82a3",
+ "accent": "#aebcff", "muted": "#a6adc8"},
+ "light": {"text": "#353841", "bg": "#ffffff", "fill": "#f5f6fa", "stroke": "#8c92ac",
+ "accent": "#3b3f7a", "muted": "#546e7a"},
+}
+# Where the files are served, under the site's public folder.
+DIAGRAM_DIR = "assets/diagrams"
+# retrobios.css shows the narrow layout below this width.
+NARROW_MEDIA = "(max-width: 37.5em)"
+
+
+def themed(document: str, theme: str) -> str:
+ """*document* with the theme's colours, the rules retrobios.css gives
+ the .rb-diagram classes on the page."""
+ c = THEMES[theme]
+ style = (
+ f""
+ )
+ head = document.index(">") + 1
+ return document[:head] + style + document[head:]
+
+
+def _size(document: str) -> tuple[str, str]:
+ match = re.match(r'