Debian Codegraph @

.github/zensical-migration.md

raw symbols SCIP
1 <!--
2 ~ Copyright (c) 2026 Arista Networks, Inc.
3 ~ Use of this source code is governed by the Apache License 2.0
4 ~ that can be found in the LICENSE file.
5 -->
6
7 # Zensical Migration Notes
8
9 **Branch:** `feature/migrate-to-zensical`
10 **Last reviewed:** June 24, 2026
11
12 This note documents the decisions, temporary workarounds, and validation steps for migrating ANTA documentation from MkDocs Material to Zensical.
13
14 ## Current State
15
16 ANTA now builds documentation with `zensical 0.0.47`.
17
18 The documentation dependency group installs:
19
20 - `zensical==0.0.47`
21 - the Zensical-compatible `mike` fork pinned to commit `2d4ad799442f4592db8ad53b179bfb33db8c69ac`
22 - `anta-zensical-extensions`, a local documentation-only package under `tools/zensical_extensions/`
23
24 CI and release workflows install the docs dependencies with:
25
26 ```bash
27 pip install --group doc -e tools/zensical_extensions
28 ```
29
30 After that install step, documentation commands do not need `PYTHONPATH`:
31
32 ```bash
33 zensical build --clean
34 zensical build --strict
35 mike deploy --push main
36 mike deploy --update-alias --push "$REF_NAME" stable
37 ```
38
39 ## Versioned Documentation
40
41 Zensical does not have native versioning yet. It currently documents versioning through a Zensical-compatible `mike` fork.
42
43 ANTA keeps the existing versioning model:
44
45 - `extra.version.provider: mike`
46 - `main` for the main-branch documentation
47 - `stable` as the release alias
48 - existing deployed versions left untouched
49
50 Do not switch back to plain PyPI `mike==2.2.0`: it builds with `mkdocs build --clean`, not `zensical build`.
51
52 The `mike` fork is pinned to an immutable commit SHA in `pyproject.toml` so documentation builds do not drift when the fork's default branch changes.
53
54 The `mike` plugin config in `mkdocs.yml` is explicit because the Zensical-compatible fork expects these keys during deploy:
55
56 ```yaml
57 - mike:
58 alias_type: symlink
59 redirect_template: null
60 deploy_prefix: ""
61 canonical_version: null
62 ```
63
64 ## Temporary Workarounds
65
66 ### Last Update Footer
67
68 Zensical 0.0.47 does not run the MkDocs hook used by `mkdocs-git-revision-date-localized-plugin`, so ANTA cannot keep that plugin for the page "Last update" footer.
69
70 ANTA uses `_extensions.zensical_git_dates` from the local `anta-zensical-extensions` package instead. Contributors and CI install it explicitly with `-e tools/zensical_extensions` alongside the root `doc` dependency group, which keeps zensical pinned in one place. The extension reads the current page path from Zensical's rendering context and sets `page.meta.git_revision_date_localized`, which lets the upstream Zensical/Material `partials/source-file.html` render the normal footer.
71
72 This workaround is tied to zensical/backlog#18. Re-test it when upgrading Zensical and remove the local extension once native support exists.
73
74 The extension is outside `docs/` because Zensical 0.0.47 copies non-page support files from `docs/` into the generated site. It lives under `tools/` instead of `.github/` so it is clearly local tooling and can be covered by the normal Python lint/type hooks.
75
76 ### Custom Code Hook Shape
77
78 This helper is a Python-Markdown extension, not a MkDocs plugin.
79
80 Zensical 0.0.47 accepts a `plugins:` key for supported compatibility shims and configuration, but it does not load arbitrary MkDocs plugin classes or call MkDocs lifecycle hooks. The `macros` shim can load custom Python modules, but it registers variables, macros, and filters for page rendering; it is not a global per-page metadata hook for this footer use case.
81
82 ### Admonitions
83
84 ANTA documentation uses standard Python-Markdown admonition syntax such as `!!! note`, `!!! info`, `!!! warning`, and `!!! tip`.
85
86 Zensical does not load the old `gh-admonitions` MkDocs plugin. ANTA also avoids GitHub-style alert syntax in `docs/` because the documentation site is the rendering target, and the standard `admonition` extension supports richer types and custom titles without another dependency.
87
88 ### GLightbox
89
90 ANTA uses Zensical's native `zensical.extensions.glightbox` Markdown extension instead of the external `mkdocs-glightbox` plugin.
91
92 The old MkDocs plugin accepted additional options such as `slide_effect`, `background`, `shadow`, `touchNavigation`, `loop`, and `effect`. Zensical's documented native extension does not support those options. ANTA keeps only the supported width setting:
93
94 ```yaml
95 - zensical.extensions.glightbox:
96 width: 90vw
97 ```
98
99 Re-test GLightbox behavior after Zensical upgrades before reintroducing any removed `mkdocs-glightbox` behavior.
100
101 ### CSS Overrides
102
103 `docs/stylesheets/extra.zensical.css` contains targeted `!important` overrides for Zensical header, search, and badge table styling. Re-test these visually when upgrading Zensical because upstream selector changes can silently change or bypass the custom styling.
104
105 ### Snippets
106
107 `docs/snippets/api_tests_overview.md` was renamed to `docs/snippets/api_tests_overview.txt`.
108
109 Reason: Zensical renders Markdown files under `docs/` as pages even when the file is intended only for snippet inclusion. Keeping the snippet in `docs/snippets/` preserves the expected source organization, while the `.txt` suffix prevents it from becoming a rendered documentation page.
110
111 ## Deliberately Out Of Scope
112
113 Historical deployed versions should not be rebuilt just to match the new Zensical UI. After this migration, it is acceptable for `/main/` to use the Zensical UI while older release folders keep the static MkDocs Material output they were originally deployed with.
114
115 ## Validation
116
117 Local validation for this branch:
118
119 ```bash
120 uv run --group doc zensical --version
121 uv run --group doc --with-editable tools/zensical_extensions zensical build --clean
122 uv run --group doc --with-editable tools/zensical_extensions zensical build --strict
123 uv run --group doc --with-editable tools/zensical_extensions mike deploy --ignore-remote-status --branch zensical-preview main
124 uv run --group doc --with-editable tools/zensical_extensions mike set-default --branch zensical-preview main
125 ```
126
127 Expected result:
128
129 - `zensical --version` reports `0.0.47`
130 - clean build reports no issues
131 - strict build reports no issues
132 - no-push `mike deploy` builds successfully
133 - `mike set-default` lets `mike serve --branch zensical-preview` load `/` without a 404; `/main/` should also remain directly accessible
134
135 ### Local multi-version preview
136
137 Use a throwaway local deploy branch to test the version selector, `stable` alias, and default redirect without touching `gh-pages`.
138
139 The following commands build three local versions:
140
141 - `main`
142 - `v0.0.0-zensical`
143 - `v0.0.1-zensical`, aliased as `stable`
144
145 ```bash
146 uv run --group doc --with-editable tools/zensical_extensions mike deploy --ignore-remote-status --branch zensical-preview main
147 uv run --group doc --with-editable tools/zensical_extensions mike deploy --ignore-remote-status --branch zensical-preview v0.0.0-zensical
148 uv run --group doc --with-editable tools/zensical_extensions mike deploy --update-alias --ignore-remote-status --branch zensical-preview v0.0.1-zensical stable
149 uv run --group doc --with-editable tools/zensical_extensions mike set-default --branch zensical-preview stable
150 uv run --group doc --with-editable tools/zensical_extensions mike serve --branch zensical-preview --dev-addr 127.0.0.1:8001
151 ```
152
153 Expected result:
154
155 - `http://127.0.0.1:8001/` redirects to `/stable/`
156 - `/stable/` serves the `v0.0.1-zensical` content
157 - `/v0.0.0-zensical/`, `/v0.0.1-zensical/`, and `/main/` are directly accessible
158 - the version selector lists all three versions and shows `stable` as an alias for `v0.0.1-zensical`
159
160 To inspect the generated metadata without starting the server:
161
162 ```bash
163 git show zensical-preview:versions.json
164 git show zensical-preview:index.html
165 ```
166
167 Preview checks used during review:
168
169 - `/main/` is generated by `zensical-0.0.47`
170 - the page footer shows "Last update"
171 - `/main/snippets/api_tests_overview/` returns 404
172 - `/main/snippets/api_tests_overview.txt` is available as a raw snippet asset
173
174 Deploy validation used during review:
175
176 - `mike deploy --push --remote origin --branch zensical-deploy-test main`
177 - `mike deploy --update-alias --push --remote origin --branch zensical-deploy-test v0.0.0-zensical-test stable`
178
179 The pushed `versions.json` contained `main`, `v0.0.0-zensical-test`, and the `stable` alias pointing to the fake release version.
180
181 The active CI documentation gate is `zensical build --strict`.
182
183 ## Follow-ups
184
185 - Re-test zensical/backlog#18 on each Zensical upgrade and remove `anta-zensical-extensions` when native Git revision metadata is available.
186 - Re-test GLightbox behavior on each Zensical upgrade if upstream adds support for more of the former `mkdocs-glightbox` option surface.
187 - Tune search tags after review if Zensical search filters are too broad or too narrow.
188 - Revisit instant previews from `doc-zensical-enable-instant-preview` after the Zensical migration merges.
189 - Before changing `main-doc.yml` or `release.yml`, test the full `mike deploy` flow against a throwaway deploy branch instead of the real `gh-pages` branch.