Skip to content

Commit a217195

Browse files
committed
Migrate from mkdocs to zensical
1 parent d3ee58a commit a217195

9 files changed

Lines changed: 443 additions & 166 deletions

File tree

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# macOS system files
22
.DS_Store
33

4-
# MkDocs build artifacts
4+
# Docs build artifacts
55
site/
6-
docs/SUMMARY.md
76
docs/clients/
87
**/docs/client/
98

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
DOCS_PORT ?= 8000
22
PYTHON_VERSION := 3.12
33

4-
.PHONY: docs docs-serve docs-clean docs-install venv
4+
.PHONY: docs docs-serve docs-clean docs-install docs-lock venv
55

66
venv:
77
uv venv --python $(PYTHON_VERSION)
88

9+
docs-lock: venv
10+
uv pip compile requirements-docs.in -o requirements-docs.txt
11+
912
docs-install: venv
10-
uv pip install -r requirements-docs.in
13+
uv pip install -r requirements-docs.txt
1114
uv pip install -e clients/*
1215

1316
docs-clean:
14-
rm -rf site docs/clients docs/SUMMARY.md
17+
rm -rf site docs/clients
1518

1619
docs-generate:
1720
uv run python scripts/docs/generate_all_doc_stubs.py
1821
uv run python scripts/docs/generate_nav.py
1922

2023
docs: docs-generate
21-
uv run mkdocs build
24+
uv run zensical build
2225

2326
docs-serve:
2427
@[ -d site ] || $(MAKE) docs

docs/hooks/copyright.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/javascript/nav-expand.js

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,59 @@
11
/**
2-
* Keep API Reference nav expanded on /clients/ pages and highlight active client.
3-
* Uses Material for MkDocs document$ observable for instant navigation compatibility.
2+
* Keep the active client highlighted and its nav section expanded across all
3+
* of its API reference pages (/clients/<name>/...).
4+
*
5+
* Zensical already auto-expands "Available Clients" and highlights the active
6+
* client on that client's own index page, but not on its nested symbol pages
7+
* (operations/, enums/, structures/, unions/, errors/). This restores that
8+
* orientation so the sidebar stays anchored while browsing a client's API.
49
*/
5-
function expandClientsNav() {
6-
if (!location.pathname.includes("/clients/")) return;
7-
document.querySelectorAll(".md-nav__item--nested").forEach(function (item) {
8-
var link = item.querySelector(":scope > .md-nav__link");
9-
if (link && link.textContent.trim().includes("Available Clients")) {
10-
// Expand "All Available Clients" drop down
11-
var toggle = item.querySelector(":scope > .md-nav__toggle");
12-
if (toggle) toggle.checked = true;
13-
item.setAttribute("data-md-state", "expanded");
14-
15-
// Highlight active client
16-
var navItems = item.querySelectorAll(".md-nav__item .md-nav__link");
17-
navItems.forEach(function (navLink) {
18-
if (navLink.href && location.pathname.includes(navLink.pathname)) {
19-
navLink.classList.add("md-nav__link--active");
20-
}
21-
});
10+
function highlightActiveClient() {
11+
// Match ".../clients/<name>/..." and capture the client segment.
12+
var match = location.pathname.match(/\/clients\/([^/]+)\//);
13+
if (!match) return;
14+
15+
// Reconstruct the client's index path, e.g. "/clients/polly/", preserving
16+
// any site base path (the docs are served under a sub-path in production).
17+
var clientRoot =
18+
location.pathname.slice(0, match.index) + "/clients/" + match[1] + "/";
19+
20+
// Scope to the primary sidebar only. The secondary "On this page" TOC uses
21+
// the same link classes, and its same-page anchors would otherwise all match
22+
// clientRoot on a client's index page and get highlighted.
23+
var sidebar = document.querySelector(".md-nav--primary");
24+
if (!sidebar) return;
25+
26+
// The client appears exactly once in the sidebar, so find it and stop —
27+
// avoids scanning the rest of the nav (hundreds of links once many clients
28+
// exist).
29+
var links = sidebar.querySelectorAll(".md-nav__link[href]");
30+
var link = null;
31+
for (var i = 0; i < links.length; i++) {
32+
if (links[i].pathname === clientRoot && !links[i].hash) {
33+
link = links[i];
34+
break;
2235
}
23-
});
36+
}
37+
if (!link) return;
38+
39+
// Highlight the client whose pages we're currently viewing.
40+
link.classList.add("md-nav__link--active");
41+
42+
// Expand every collapsible ancestor (incl. "Available Clients") so the
43+
// highlighted link is visible. Expansion is driven by the toggle checkbox.
44+
var item = link.closest(".md-nav__item--nested");
45+
while (item) {
46+
var toggle = item.querySelector(":scope > .md-nav__toggle");
47+
if (toggle) toggle.checked = true;
48+
var parent = item.parentElement;
49+
item = parent && parent.closest(".md-nav__item--nested");
50+
}
2451
}
2552

26-
// Subscribe to Material's document$ observable for instant navigation support
27-
document$.subscribe(expandClientsNav);
28-
// Also run on initial page load
29-
expandClientsNav();
53+
// Re-run on every instant-navigation page load; fall back to a one-time run if
54+
// the document$ observable isn't available.
55+
if (typeof document$ !== "undefined" && document$.subscribe) {
56+
document$.subscribe(highlightActiveClient);
57+
} else {
58+
highlightActiveClient();
59+
}

mkdocs.yml

Lines changed: 0 additions & 98 deletions
This file was deleted.

requirements-docs.in

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
mkdocs==1.6.1
2-
mkdocstrings[python]==1.0.0
3-
mkdocs-material==9.7.0
4-
mkdocs-literate-nav==0.6.1
1+
mkdocstrings[python]~=1.0.4
2+
zensical~=0.0.46

requirements-docs.txt

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile requirements-docs.in -o requirements-docs.txt
3+
click==8.4.2
4+
# via
5+
# mkdocs
6+
# zensical
7+
deepmerge==2.1.0
8+
# via zensical
9+
ghp-import==2.1.0
10+
# via mkdocs
11+
griffelib==2.1.0
12+
# via mkdocstrings-python
13+
jinja2==3.1.6
14+
# via
15+
# mkdocs
16+
# mkdocstrings
17+
# zensical
18+
markdown==3.10.2
19+
# via
20+
# mkdocs
21+
# mkdocs-autorefs
22+
# mkdocstrings
23+
# pymdown-extensions
24+
# zensical
25+
markupsafe==3.0.3
26+
# via
27+
# jinja2
28+
# mkdocs
29+
# mkdocs-autorefs
30+
# mkdocstrings
31+
mergedeep==1.3.4
32+
# via
33+
# mkdocs
34+
# mkdocs-get-deps
35+
mkdocs==1.6.1
36+
# via
37+
# mkdocs-autorefs
38+
# mkdocstrings
39+
mkdocs-autorefs==1.4.4
40+
# via
41+
# mkdocstrings
42+
# mkdocstrings-python
43+
mkdocs-get-deps==0.2.2
44+
# via mkdocs
45+
mkdocstrings==1.0.4
46+
# via
47+
# -r requirements-docs.in
48+
# mkdocstrings-python
49+
mkdocstrings-python==2.0.5
50+
# via mkdocstrings
51+
packaging==26.2
52+
# via mkdocs
53+
pathspec==1.1.1
54+
# via mkdocs
55+
platformdirs==4.10.0
56+
# via mkdocs-get-deps
57+
pygments==2.20.0
58+
# via zensical
59+
pymdown-extensions==11.0
60+
# via
61+
# mkdocstrings
62+
# zensical
63+
python-dateutil==2.9.0.post0
64+
# via ghp-import
65+
pyyaml==6.0.3
66+
# via
67+
# mkdocs
68+
# mkdocs-get-deps
69+
# pymdown-extensions
70+
# pyyaml-env-tag
71+
# zensical
72+
pyyaml-env-tag==1.1
73+
# via mkdocs
74+
six==1.17.0
75+
# via python-dateutil
76+
tomli==2.4.1
77+
# via zensical
78+
watchdog==6.0.0
79+
# via mkdocs
80+
zensical==0.0.46
81+
# via -r requirements-docs.in

0 commit comments

Comments
 (0)