Skip to content

Commit 2c4d179

Browse files
committed
Update config for multi-versions
1 parent f48082a commit 2c4d179

4 files changed

Lines changed: 64 additions & 5 deletions

File tree

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,14 @@ scripts/modules_analysis.json
157157

158158
# Man pages
159159
share/man/
160+
161+
# Test files for multi-version docs
162+
test_version_switcher.html
163+
test-vale-doc.md
164+
Scripts/test_multiversion*.py
165+
Scripts/test_multiversion*.sh
166+
167+
# Test deployment directories generated by scripts
168+
test_deployment/
169+
test_deployment_quick/
170+
test_deployment_full/

docs/_static/robots.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Robots.txt for OpenSPP Documentation
2+
# Allow indexing of stable documentation, block preview versions
3+
4+
User-agent: *
5+
# Block preview documentation branches
6+
Disallow: /previews/
7+
8+
# Allow stable and versioned releases
9+
Allow: /
10+
11+
# Sitemap location
12+
Sitemap: https://docs.openspp.org/sitemap.xml

docs/_templates/layout.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{% extends "sphinx_book_theme/layout.html" %}
22
{%- block extrahead %}
33
{{ super() }}
4+
{%- if is_preview %}
5+
<!-- Prevent search engines from indexing preview documentation -->
6+
<meta name="robots" content="noindex,nofollow,noarchive">
7+
{%- endif %}
48
<!-- Review Status System - DISABLED
59
<link rel="stylesheet" href="{{ pathto('_static/review_status.css', 1) }}" type="text/css" />
610
<script src="{{ pathto('_static/review_status_simple.js', 1) }}"></script>

docs/conf.py

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import re
1212
import sys
1313
import logging
14+
import json
1415

1516
from pathlib import Path
1617
_logger = logging.getLogger(__name__)
@@ -137,6 +138,17 @@
137138
# The full version, including alpha/beta/rc tags.
138139
release = "1.1"
139140

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+
140152
# -- General configuration ----------------------------------------------------
141153

142154
# Add any paths that contain templates here, relative to this directory.
@@ -372,11 +384,15 @@
372384
"**/README.rst",
373385
]
374386

375-
html_js_files = ["patch_scrollToActive.js", "search_shortcut.js"]
387+
html_js_files = ["patch_scrollToActive.js", "search_shortcut.js", "version_switcher.js"]
376388

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 = []
380396

381397
html_static_path = [
382398
"_static", # Last path wins. So this one will override the default theme's static files.
@@ -507,6 +523,21 @@
507523
""",
508524
}
509525

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+
510541
googleanalytics_id = 'G-RS4T4ZPG52'
511542

512543
# The name for this set of Sphinx documents. If None, it defaults to
@@ -517,7 +548,7 @@
517548
html_use_index = True
518549

519550
# Used by sphinx_sitemap to generate a sitemap
520-
html_baseurl = "https://docs.openspp.org/"
551+
html_baseurl = DOCS_BASEURL
521552
sitemap_url_scheme = "{link}"
522553

523554
# -- Options for HTML help output -------------------------------------------------
@@ -554,6 +585,7 @@
554585
"github_repo": "documentation", # Repo name
555586
"github_version": "main", # Version
556587
"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
557589
}
558590

559591
# An extension that allows replacements for code blocks that

0 commit comments

Comments
 (0)