Skip to content

Expose every tools script as a dec-tool subcommand - #260

Merged
rpietzsch merged 4 commits into
feature/zensicalfrom
feature/zensical-addons
Sep 4, 2026
Merged

Expose every tools script as a dec-tool subcommand#260
rpietzsch merged 4 commits into
feature/zensicalfrom
feature/zensical-addons

Conversation

@seebi

@seebi seebi commented Sep 4, 2026

Copy link
Copy Markdown
Member

💪 What

  • Adds build-navigation, check-zensical-output and localize-bundle-assets as dec-tool subcommands, so all six build/generate/check scripts share one entry point instead of three of them being called as poetry run python tools/<script>.py
  • Renames tools/build_nav.py to tools/build_navigation.py so file and command agree, as they already do for the other five
  • Removes the __main__ blocks: dec-tool is now the only entry point, matching update-icons, update-di-reference and update-integrations
  • Adds --check to build-navigation, which diffs the generated navigation against the -o target and exits 1 on drift, replacing the mktemp/trap/diff shell block in the Taskfile
  • Renames the nav task to update:navigation and check:nav to check:navigation, grouping both with the existing update:* and check:* families
  • Updates the pre-commit nav-drift hook to the new task and module names
  • Rewrites tools/README.md, which said "This directory is not used at the moment", into a reference for all six subcommands and the tasks that call them
  • Drops the README's tag-listing workaround section: Zensical 0.0.58 ships native listings and chip links, and the two files that section described were deleted in 1b969f4
  • Adds test coverage for the navigation builder, taking it from 2 tests to 28: dir_title's acronym rule, discover_dir's MkDocs-like ordering, expand_dir's no-bare-directory behaviour, expand_item's title inheritance and inline sections, both of render_nav's error paths, and the CLI cases that were missing

The new commands follow the conventions the existing ones already set: named options with repo-relative defaults and show_default, the command writing its own output, and progress on stdout via click.echo.

🤔 Why

  • Half the tooling was reachable through dec-tool and half through direct script paths, so the two halves drifted apart in argument handling, defaults and error reporting. One entry point makes dec-tool --help an accurate inventory of what this repo can do to itself.
  • The navigation drift check lived as shell inside Taskfile.yml: a temp file, a trap, a diff and hand-written echo messages. Moving it into --check makes it testable, and it is now covered by unit tests rather than only by running the task.
  • The navigation builder generates the whole 571-line nav.yml, and until now nothing pinned its behaviour. Its rules are the kind that break quietly: dir_title capitalises only all-lowercase names, which is what stops link-IDS-event-to-KG becoming "Link Ids Event To Kg", and expand_dir walks a .pages-less directory because a bare directory reference empties the sidebar under navigation.tabs and drops pages from the navigation. Both now have tests, and both were confirmed to fail when the rule is reverted.
  • task nav gave no hint that it regenerates nav.yml, and sorted nowhere near the other regeneration tasks. update:navigation and check:navigation put both halves where you would look for them.
  • The README described a tag-listing renderer and a tags.html override as features "reimplemented here", pointing at two files that no longer exist. The failure message of the check that guards tag chips named the deleted override too, which is the worst possible moment to read a stale hint.

👀 Usage

poetry run dec-tool --help                    # six subcommands
poetry run dec-tool build-navigation --help   # --docs-dir, -o/--output-file, --check

task update:navigation    # regenerate nav.yml from docs/**/.pages
task check:navigation     # fail on drift, with a diff

👩‍🔬 How to validate

  1. poetry run dec-tool --help — six subcommands, three of them new.
  2. Reorder two entries in any docs/**/.pages file, then task check:navigation. It prints a unified diff of exactly that change, tells you to run task update:navigation, and exits 1. The same happens on git commit via the pre-commit hook.
  3. task update:navigation, then git diff nav.yml — empty, i.e. the rewritten generator reproduces the committed file byte for byte. Revert your .pages edit afterwards.
  4. task build — the build ends with localize-bundle-assets rewriting the two unpkg URLs to the vendored glightbox copies.
  5. task check:output — reports the tag-chip checks as PASS and social cards / revision dates as PEND.

🧹 Open issues (not addressed here)

Deliberately left for follow-up work, recorded here so they are visible at merge time:

  • tasks/ is largely obsolete. tasks/spec.md carries its own verdict — "removed 2026-09-03 … Lifetime: delete the moment Zensical ships listings" — and Zensical shipped them in 0.0.58. tasks/backlog.md marks B0-B8 and C1-C4 done and describes files that were deleted. tasks/check_zensical_output.py is the copy that handoff.md T8a said to move into tools/; that happened, and the two have since diverged. All three can go once feature/zensical lands on main.
  • tasks/handoff.md is stale in places. It references tools/build_nav.py and python tools/check_zensical_output.py site, both dead paths after this PR, and its section 5 still lists tag listings as deferred. Its T1–T8 are all verifiably complete — the remaining value is the record of why the migration looks the way it does.
  • check-zensical-output and localize-bundle-assets have no tests. Only the navigation builder was covered here. Testing the former first needs a decision on its module-level failures/notices lists, which report() appends to: they make results accumulate across invocations in one process, so tests would have to assert on globals or the checks need to return their results instead.
  • Two Zensical gaps remain open. Social cards (Support material/social plugin functionality zensical/backlog#37) and revision dates (Support mkdocs-git-revision-date-localized plugin functionality zensical/backlog#18) are still missing and still reported as PEND on every build. They are the reason the migration is not finished, and the merge decision on feature/zensical should account for them.

🔗 Related links

seebi and others added 3 commits September 4, 2026 09:17
The task regenerates nav.yml from the docs/**/.pages files, which puts it
in the same family as update:cmemc, update:icons and the other regeneration
tasks. Rename it accordingly and move it next to them, and update the two
places that referenced the old name: the hint printed by check:nav and the
navigation section of the README.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D6WBueY2LvLdFZeNv2upnH
Three scripts were still invoked as `poetry run python tools/<script>.py`
while the other three had long been click commands on the dec-tool group.
Wire the remaining ones up the same way, following the conventions the
existing commands already established: named options with repo-relative
defaults and show_default, the command writing its own output, and progress
on stdout via click.echo.

  build-navigation        --docs-dir docs, -o nav.yml, --check
  check-zensical-output   --site-dir site
  localize-bundle-assets  --site-dir site

build_nav.py becomes build_navigation.py so that file and command agree, as
they do for the other five. The __main__ blocks are gone: dec-tool is now the
only entry point.

--check is new. It compares the generated navigation against whatever -o
points at instead of writing it, prints a unified diff and exits 1 on drift,
which replaces the mktemp/trap/diff shell block in check:nav - renamed to
check:navigation to match update:navigation. The pre-commit nav-drift hook
follows both the task rename and the module rename.

Verified with `task check` (all four stages, including a full build) and
`pytest -m "not integration"`; `task update:navigation` regenerates nav.yml
byte-identically.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D6WBueY2LvLdFZeNv2upnH
Bumping to Zensical 0.0.58 removed tools/render_tag_listings.py, the
overrides/partials/tags.html partial and their tests, but left the README
describing both as features "reimplemented here" - it pointed at two files
that no longer exist. Tag listings and tag chip links are native now, so say
that instead, and keep the paragraph on what check-zensical-output still
guards: chips must link somewhere, and their anchors must exist on /tags/.

The failure text of that very check named the deleted partial, which is the
worst possible moment to read a stale hint. It now asks about Zensical.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D6WBueY2LvLdFZeNv2upnH
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Test Results

1 files  ±0  2 suites  ±0   0s ⏱️ ±0s
2 tests ±0  0 ✅ ±0  0 💤 ±0  2 ❌ ±0 
2 runs  ±0  -7 ✅ ±0  0 💤 ±0  9 ❌ ±0 

For more details on these failures, see this check.

Results for commit a6911b9. ± Comparison against base commit 1b969f4.

♻️ This comment has been updated with latest results.

The builder had two tests, both on the click layer, while the logic that
actually derives the navigation was unpinned. That logic carries the subtle
rules: dir_title capitalises only all-lowercase names, which is what keeps
"link-IDS-event-to-KG" from becoming "Link Ids Event To Kg", and expand_dir
walks a directory that has no .pages instead of emitting a bare reference -
a fix whose 12-line comment explains that bare references empty the sidebar
under navigation.tabs and drop pages from the navigation entirely.

Adds coverage for dir_title, read_pages, has_markdown, discover_dir's
MkDocs-like ordering, expand_dir, expand_item, build_nav_list and render_nav's
two error paths, plus the CLI cases that were missing: --check against a
not-yet-existing file, and a --docs-dir that is not there.

Checked that the tests can fail: making dir_title capitalise unconditionally
breaks the acronym case, and reverting expand_dir to a bare directory
reference breaks five.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D6WBueY2LvLdFZeNv2upnH
@seebi
seebi marked this pull request as ready for review September 4, 2026 08:35
@seebi
seebi marked this pull request as draft September 4, 2026 08:35
@seebi
seebi marked this pull request as ready for review September 4, 2026 08:43
@seebi
seebi requested a review from rpietzsch September 4, 2026 08:43

@rpietzsch rpietzsch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, also tested and validated locally. thanks for the refinements/integration in tools 🙌

@rpietzsch
rpietzsch merged commit 69cc006 into feature/zensical Sep 4, 2026
2 of 3 checks passed
@rpietzsch
rpietzsch deleted the feature/zensical-addons branch September 4, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants