From d074e8169fdeaa1b0f6f047fe2b01406e2241fd0 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 5 Oct 2026 18:28:59 +0100 Subject: [PATCH] Use shared banner and board section navigation --- scripts/board.py | 47 +++++++++++++++++++++-------------- test_autonerves/test_board.py | 2 +- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/scripts/board.py b/scripts/board.py index cfdaecb..fd7d299 100644 --- a/scripts/board.py +++ b/scripts/board.py @@ -1272,13 +1272,6 @@ def _render_html_index(snap: dict) -> str: files = snap.get("files") or [] ov = snap.get("overrides") or [] found = [s for s in snap.get("sources") or [] if s.get("found")] - stats = t_.stats((len(files), "files"), (len(found), "sources"), - (sum(len(f["keys"]) for f in files), "keys"), - (len(ov), "overrides"), (len(orphans(snap)), "orphaned"), - (sum(len(v) for v in unused_keys(snap).values()), - "possibly unused"), - (len(snap.get("env_vars") or []), "env vars")) \ - if hasattr(t_, "stats") else "" rows = [] for s in snap.get("sources") or []: name = (f"{_esc(s['repo'])}" @@ -1293,7 +1286,7 @@ def _render_html_index(snap: dict) -> str: f"{_esc(s['kind'])}{s['files']}" f"{s['lines']}{s['keys']}" f"{s['priors']}{err}") - overview = ("

Sources

RepoKind" + overview = ("

Sources

" "" + "".join(rows) + "
RepoKind" "FilesLinesKeysPriorsUnparseable
") ov_rows = [] @@ -1317,7 +1310,7 @@ def _render_html_index(snap: dict) -> str: override = "" if ov_rows: override = ( - "

Override map

Each workspace file against " + "

Override map

Each workspace file against " "the same path across its library stack, in autonerves lookup " "order (e.g. lens → galaxy → array → fit). " "differs the workspace changes the value the libraries give; " @@ -1330,7 +1323,7 @@ def _render_html_index(snap: dict) -> str: tooling = [f for f in files if f.get("tooling")] tool_html = "" if tooling: - tool_html = ("

Workspace tooling

" + tool_html = ("

Workspace tooling

" "build/ lists for CI and the release build — " "workspace-local, not library settings.

") env_html = "" if snap.get("env_vars"): - env_html = ("

Environment variables

The " + env_html = ("

Environment variables

The " "PYAUTO_* switches autonerves reads — options " "that live outside the YAML.

" "" + "".join( @@ -1349,7 +1342,7 @@ def _render_html_index(snap: dict) -> str: for e in snap["env_vars"]) + "
VariableWhat it does
") problems = "" if parse_errors(snap): - problems = ("

Unparseable files

    " + "".join( + problems = ("

    Unparseable files

      " + "".join( f"
    • " f"{_esc(f['repo'])}/{_esc(f['path'])} — " f"{_esc(f['error'])}
    • " for f in parse_errors(snap)) @@ -1370,11 +1363,11 @@ def _render_html_index(snap: dict) -> str: f"{_esc(lib)} — {len(keys)} key" f"{'s' if len(keys) != 1 else ''}" f"
        {lis}
      ") - unused_html = ("

      Possibly unused config keys

      " + unused_html = ("

      Possibly unused config keys

      " + _esc(UNUSED_CAVEAT).replace("`", "").replace("*", "") + "

      " + "".join(groups)) elif snap.get("lookups"): - unused_html = ("

      Possibly unused config keys

      " + unused_html = ("

      Possibly unused config keys

      " "none — every library settings key is read.

      ") errors = "" if snap.get("errors"): @@ -1388,13 +1381,25 @@ def _render_html_index(snap: dict) -> str: gh_link = f' · GitHub' if gh else "" lede = ("Every config file and option across the libraries and the " "workspaces that override them — read-only.") - body = f"""{t_.hero(BOARD_KEY, "Board", lede)} + navigation = [ + {"href": "#search", "label": "Search keys", "count": sum(len(f["keys"]) for f in files)}, + {"href": "#sources", "label": "Sources", "count": len(found)}, + ] + for target, label, count, present in [ + ("overrides", "Overrides", len(ov), override), + ("unused", "Possibly unused", sum(len(v) for v in unused.values()), unused_html), + ("problems", "Unparseable files", len(parse_errors(snap)), problems), + ("environment", "Environment variables", len(snap.get("env_vars") or []), env_html), + ("tooling", "Workspace tooling", len(tooling), tool_html), + ]: + if present: + navigation.append({"href": "#" + target, "label": label, "count": count}) + body = f"""{t_.hero(BOARD_KEY, "Board", lede, navigation=navigation)}

      {st.upper()} {_esc(_summary(snap))}

      -{stats}

      markdown version · board.json{gh_link}

      -

      Search

      +

      @@ -1504,7 +1509,7 @@ def _render_html_repo(snap: dict, name: str) -> str: groups.setdefault(d, []).append(f) parts = [] for d in sorted(groups, key=lambda g: (g != "(top level)", g)): - parts.append(f"

      {_esc(d)} " + parts.append(f"

      {_esc(d)} " f"({len(groups[d])})

      " + "".join( _file_html(snap, f, ovs.get(f["path"])) for f in groups[d]) + "
      ") @@ -1513,7 +1518,11 @@ def _render_html_repo(snap: dict, name: str) -> str: gh = (f' · GitHub' if src.get("github") else "") lede = f"{_esc(name)} · {_esc(src['config'])}/" - body = f"""{t_.hero(BOARD_KEY, "Board", lede)} + navigation = [{"href": "../index.html", "label": "All sources"}, + {"href": "#pfilter", "label": "Filter files", "count": len(files)}] + navigation.extend({"href": "#group-" + slug(d), "label": d, "count": len(groups[d])} + for d in sorted(groups, key=lambda g: (g != "(top level)", g))) + body = f"""{t_.hero(BOARD_KEY, "Board", lede, navigation=navigation)}

      ← all sources · {src.get('kind')} · {len(files)} files · {src.get('lines', 0)} lines{stack}{gh}

      {kind} {lede}", + hero=lambda key, kind, lede="", *, navigation=(): f"
      {kind} {lede}
      ", stats=lambda *pairs: "".join(f"{n}{label}" for n, label in pairs), board_links=lambda base, current=None: {"mind": f"{base}/Mind/"}, boards_footer=lambda links, current: "
        ",