|
42 | 42 | _build_date_value = _dt.date.today() |
43 | 43 | build_date = _build_date_value.strftime("%d %b %Y") |
44 | 44 |
|
| 45 | +# Documentation version channel for this build -- the top-level URL segment the |
| 46 | +# site is hosted under (docs.openmv.io/<channel>/...). The CI sets it: "dev" for |
| 47 | +# the rolling master build, "v5.0.0" etc. for a tagged release snapshot. Old |
| 48 | +# release snapshots are frozen HTML and never rebuilt; "/latest/" and "/" are |
| 49 | +# redirect shims to the newest release. Defaults to "dev" for local builds. |
| 50 | +doc_channel = os.environ.get("OPENMV_DOCS_CHANNEL", "dev") |
| 51 | + |
45 | 52 | # Values exposed to topindex.html and footer templates. |
46 | 53 | # Resolve this submodule's HEAD SHA at build time so "Edit this |
47 | 54 | # page" and the AI dropdown's raw-source link both pin to the exact |
|
75 | 82 |
|
76 | 83 | # Site root — used by sphinx-llms-txt to emit absolute URLs in |
77 | 84 | # /llms.txt and by Shibuya's "Copy page" / "Open in ChatGPT" dropdown |
78 | | -# to fetch raw page source from /_sources/. |
79 | | -html_baseurl = "https://docs.openmv.io/" |
| 85 | +# to fetch raw page source from /_sources/. Version-channel aware: every build |
| 86 | +# is hosted under docs.openmv.io/<channel>/. |
| 87 | +html_baseurl = "https://docs.openmv.io/{}/".format(doc_channel) |
80 | 88 |
|
81 | 89 | # -- Landing page code examples (rendered via Pygments to match site code style) -- |
82 | 90 | from pygments import highlight as _pygments_highlight |
@@ -356,38 +364,57 @@ def _render_landing_code(src): |
356 | 364 | # sphinx-build -b html -D language=zh_CN . _build/html/zh_CN |
357 | 365 | # sphinx-build -b html -D language=zh_TW . _build/html/zh_TW |
358 | 366 | # |
359 | | -# The zh_CN / zh_TW entries below go live once those builds are deployed. |
360 | | -# English first (default), then A–Z by English language name. |
| 367 | +# (display name, language subdirectory, hreflang). English is the bare root of |
| 368 | +# the version channel; each translation lives under <subdir>/. English first, |
| 369 | +# then A–Z by English language name. |
| 370 | +_languages = [ |
| 371 | + ("English", "", "en"), |
| 372 | + ("العربية", "ar", "ar"), # Arabic |
| 373 | + ("简体中文", "zh_CN", "zh-Hans"), # Chinese (Simplified) |
| 374 | + ("繁體中文", "zh_TW", "zh-Hant"), # Chinese (Traditional) |
| 375 | + ("Hrvatski", "hr", "hr"), # Croatian |
| 376 | + ("Čeština", "cs", "cs"), # Czech |
| 377 | + ("Nederlands", "nl", "nl"), # Dutch |
| 378 | + ("Suomi", "fi", "fi"), # Finnish |
| 379 | + ("Français", "fr", "fr"), # French |
| 380 | + ("Deutsch", "de", "de"), # German |
| 381 | + ("עברית", "he", "he"), # Hebrew |
| 382 | + ("Magyar", "hu", "hu"), # Hungarian |
| 383 | + ("Bahasa Indonesia", "id", "id"), # Indonesian |
| 384 | + ("Italiano", "it", "it"), # Italian |
| 385 | + ("日本語", "ja", "ja"), # Japanese |
| 386 | + ("한국어", "ko", "ko"), # Korean |
| 387 | + ("Polski", "pl", "pl"), # Polish |
| 388 | + ("Português (Brasil)", "pt_BR", "pt-BR"), # Portuguese (Brazil) |
| 389 | + ("Português (Portugal)", "pt_PT", "pt-PT"), # Portuguese (Portugal) |
| 390 | + ("Română", "ro", "ro"), # Romanian |
| 391 | + ("Русский", "ru", "ru"), # Russian |
| 392 | + ("Español", "es", "es"), # Spanish |
| 393 | + ("Svenska", "sv", "sv"), # Swedish |
| 394 | + ("ไทย", "th", "th"), # Thai |
| 395 | + ("Türkçe", "tr", "tr"), # Turkish |
| 396 | + ("Українська", "uk", "uk"), # Ukrainian |
| 397 | + ("Tiếng Việt", "vi", "vi"), # Vietnamese |
| 398 | +] |
| 399 | +# Channel-prefixed URL patterns; %s is the page name (filled by Shibuya's |
| 400 | +# i18n_link). Switching language keeps the current version + page, e.g. |
| 401 | +# "/dev/de/%s.html". English is "/dev/%s.html". |
361 | 402 | html_context["languages"] = [ |
362 | | - ("English", "/%s.html", "en"), |
363 | | - ("العربية", "/ar/%s.html", "ar"), # Arabic |
364 | | - ("简体中文", "/zh_CN/%s.html", "zh-Hans"), # Chinese (Simplified) |
365 | | - ("繁體中文", "/zh_TW/%s.html", "zh-Hant"), # Chinese (Traditional) |
366 | | - ("Hrvatski", "/hr/%s.html", "hr"), # Croatian |
367 | | - ("Čeština", "/cs/%s.html", "cs"), # Czech |
368 | | - ("Nederlands", "/nl/%s.html", "nl"), # Dutch |
369 | | - ("Suomi", "/fi/%s.html", "fi"), # Finnish |
370 | | - ("Français", "/fr/%s.html", "fr"), # French |
371 | | - ("Deutsch", "/de/%s.html", "de"), # German |
372 | | - ("עברית", "/he/%s.html", "he"), # Hebrew |
373 | | - ("Magyar", "/hu/%s.html", "hu"), # Hungarian |
374 | | - ("Bahasa Indonesia", "/id/%s.html", "id"), # Indonesian |
375 | | - ("Italiano", "/it/%s.html", "it"), # Italian |
376 | | - ("日本語", "/ja/%s.html", "ja"), # Japanese |
377 | | - ("한국어", "/ko/%s.html", "ko"), # Korean |
378 | | - ("Polski", "/pl/%s.html", "pl"), # Polish |
379 | | - ("Português (Brasil)", "/pt_BR/%s.html", "pt-BR"), # Portuguese (Brazil) |
380 | | - ("Português (Portugal)", "/pt_PT/%s.html", "pt-PT"), # Portuguese (Portugal) |
381 | | - ("Română", "/ro/%s.html", "ro"), # Romanian |
382 | | - ("Русский", "/ru/%s.html", "ru"), # Russian |
383 | | - ("Español", "/es/%s.html", "es"), # Spanish |
384 | | - ("Svenska", "/sv/%s.html", "sv"), # Swedish |
385 | | - ("ไทย", "/th/%s.html", "th"), # Thai |
386 | | - ("Türkçe", "/tr/%s.html", "tr"), # Turkish |
387 | | - ("Українська", "/uk/%s.html", "uk"), # Ukrainian |
388 | | - ("Tiếng Việt", "/vi/%s.html", "vi"), # Vietnamese |
| 403 | + (label, |
| 404 | + "/{c}/{p}%s.html".format(c=doc_channel, p=(sub + "/" if sub else "")), |
| 405 | + hreflang) |
| 406 | + for (label, sub, hreflang) in _languages |
389 | 407 | ] |
390 | 408 |
|
| 409 | +# Documentation-version switcher (Shibuya's nav-versions component, rendered |
| 410 | +# left of the language switcher). ``current_version`` is the button label. |
| 411 | +# ``versions`` is only a bootstrap so the element renders; the real, |
| 412 | +# always-current list -- with per-page links that keep the current language -- |
| 413 | +# is populated client-side from /versions.json by static/nav-versions.js, so |
| 414 | +# even frozen old snapshots show the full, current version list. |
| 415 | +html_context["current_version"] = doc_channel |
| 416 | +html_context["versions"] = [(doc_channel, "")] |
| 417 | + |
391 | 418 | # There are two options for replacing |today|: either, you set today to some |
392 | 419 | # non-false value, then it is used: |
393 | 420 | # today = '' |
@@ -577,6 +604,10 @@ def _render_landing_code(src): |
577 | 604 | # Re-publish --sy-s-offset-top from the real header height so sticky |
578 | 605 | # elements stay aligned when the navbar wraps (long translated labels). |
579 | 606 | "navbar-height.js", |
| 607 | + # Populate the version switcher from /versions.json (per-page links that |
| 608 | + # keep the current language), so even frozen old snapshots list every |
| 609 | + # version. See static/nav-versions.js. |
| 610 | + "nav-versions.js", |
580 | 611 | ] |
581 | 612 | # Add any extra paths that contain custom files (such as robots.txt or |
582 | 613 | # .htaccess) here, relative to this directory. These files are copied |
|
0 commit comments