|
11 | 11 | import re |
12 | 12 | import sys |
13 | 13 | import logging |
| 14 | +import json |
14 | 15 |
|
15 | 16 | from pathlib import Path |
16 | 17 | _logger = logging.getLogger(__name__) |
|
137 | 138 | # The full version, including alpha/beta/rc tags. |
138 | 139 | release = "1.1" |
139 | 140 |
|
| 141 | +# -- Multi-version configuration ---------------------------------------------- |
| 142 | +# Support environment-driven configuration for multi-version builds |
| 143 | +DOCS_VERSION = os.getenv("DOCS_VERSION", "stable") |
| 144 | +DOCS_BASEURL = os.getenv("DOCS_BASEURL", "https://docs.openspp.org/") |
| 145 | +IS_PREVIEW = os.getenv("IS_PREVIEW", "0") == "1" |
| 146 | + |
| 147 | +# Update version display based on environment |
| 148 | +if DOCS_VERSION != "stable": |
| 149 | + version = DOCS_VERSION |
| 150 | + release = DOCS_VERSION |
| 151 | + |
140 | 152 | # -- General configuration ---------------------------------------------------- |
141 | 153 |
|
142 | 154 | # Add any paths that contain templates here, relative to this directory. |
|
372 | 384 | "**/README.rst", |
373 | 385 | ] |
374 | 386 |
|
375 | | -html_js_files = ["patch_scrollToActive.js", "search_shortcut.js"] |
| 387 | +html_js_files = ["patch_scrollToActive.js", "search_shortcut.js", "version_switcher.js"] |
376 | 388 |
|
377 | | -html_extra_path = [ |
378 | | - "robots.txt", |
379 | | -] |
| 389 | +# Only include robots.txt for stable builds |
| 390 | +if not IS_PREVIEW: |
| 391 | + html_extra_path = [ |
| 392 | + "_static/robots.txt", |
| 393 | + ] |
| 394 | +else: |
| 395 | + html_extra_path = [] |
380 | 396 |
|
381 | 397 | html_static_path = [ |
382 | 398 | "_static", # Last path wins. So this one will override the default theme's static files. |
|
507 | 523 | """, |
508 | 524 | } |
509 | 525 |
|
| 526 | +# Version switcher configuration (for future theme versions) |
| 527 | +# Note: sphinx-book-theme 0.3.3 doesn't have built-in version switcher support |
| 528 | +# Using custom JavaScript implementation in version_switcher.js instead |
| 529 | +html_theme_options["switcher"] = { |
| 530 | + "json_url": "https://docs.openspp.org/_static/switcher.json", |
| 531 | + "version_match": DOCS_VERSION, |
| 532 | +} |
| 533 | + |
| 534 | +# Add announcement banner for preview builds |
| 535 | +if IS_PREVIEW: |
| 536 | + html_theme_options["announcement"] = f""" |
| 537 | + <p><strong>⚠️ Preview Documentation</strong>: You are viewing a preview build from branch <code>{DOCS_VERSION}</code>. |
| 538 | + For the stable documentation, visit <a href="https://docs.openspp.org/">docs.openspp.org</a></p> |
| 539 | + """ |
| 540 | + |
510 | 541 | googleanalytics_id = 'G-RS4T4ZPG52' |
511 | 542 |
|
512 | 543 | # The name for this set of Sphinx documents. If None, it defaults to |
|
517 | 548 | html_use_index = True |
518 | 549 |
|
519 | 550 | # Used by sphinx_sitemap to generate a sitemap |
520 | | -html_baseurl = "https://docs.openspp.org/" |
| 551 | +html_baseurl = DOCS_BASEURL |
521 | 552 | sitemap_url_scheme = "{link}" |
522 | 553 |
|
523 | 554 | # -- Options for HTML help output ------------------------------------------------- |
|
554 | 585 | "github_repo": "documentation", # Repo name |
555 | 586 | "github_version": "main", # Version |
556 | 587 | "conf_py_path": "/docs/", # Path in the checkout to the docs root |
| 588 | + "is_preview": IS_PREVIEW, # Flag for preview builds to add noindex meta tag |
557 | 589 | } |
558 | 590 |
|
559 | 591 | # An extension that allows replacements for code blocks that |
|
0 commit comments