1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
From: Christian Bayle <bayle@debian.org>
Date: Sat, 6 Sep 2025 22:52:43 +0200
Subject: Merge Get-data-from-env and Add-option-to-skip-theme-update patches
Forwarded: not-needed
---
src/rocm_docs/projects.py | 10 ++++++++--
src/rocm_docs/theme.py | 16 +++++++++++-----
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/src/rocm_docs/projects.py b/src/rocm_docs/projects.py
index f479223..8368641 100644
--- a/src/rocm_docs/projects.py
+++ b/src/rocm_docs/projects.py
@@ -411,7 +411,12 @@ def _update_theme_configs(
flavor: str,
) -> None:
"""Update configurations for use in theme.py"""
- latest_version_list = requests.get(
+ # In case of no internet access
+ if "ROCM_DOCS_SKIP_UPDATE_THEME_CONFIGS" in os.environ:
+ return
+
+ if (latest_version_list := str(os.getenv('rocm_data_versions'))) == '':
+ latest_version_list = requests.get(
"https://raw.githubusercontent.com/ROCm/rocm-docs-core/new_data/latest_version.txt"
).text.strip()
latest_version_dict = theme._parse_version(latest_version_list)
@@ -421,7 +426,8 @@ def _update_theme_configs(
# Some component's docs branch has "docs-" prefix, others do not
latest_version_string_list += [f"docs-{latest_version}", latest_version]
- release_candidate = requests.get(
+ if release_candidate := os.getenv('release_candidate') is None:
+ release_candidate = requests.get(
"https://raw.githubusercontent.com/ROCm/rocm-docs-core/new_data/release_candidate.txt"
).text.strip("\r\n")
release_candidate_string = f"docs-{release_candidate}"
diff --git a/src/rocm_docs/theme.py b/src/rocm_docs/theme.py
index 440e4b0..a30986a 100644
--- a/src/rocm_docs/theme.py
+++ b/src/rocm_docs/theme.py
@@ -14,6 +14,7 @@ from pydata_sphinx_theme.utils import ( # type: ignore[import-untyped]
from sphinx.application import Sphinx
from rocm_docs import util
+import os
logger = sphinx.util.logging.getLogger(__name__)
@@ -63,19 +64,22 @@ def _add_custom_context(
context: dict[str, str | dict[str, str]],
doctree: object, # noqa: ARG001
) -> None:
- latest_version_list = _get_version_from_url(
+ if (latest_version_list := str(os.getenv('rocm_data_versions'))) == '':
+ latest_version_list = _get_version_from_url(
"https://raw.githubusercontent.com/ROCm/rocm-docs-core/new_data/latest_version.txt"
)
context["header_latest_version"] = _parse_version(latest_version_list)
- header_release_candidate_version = _get_version_from_url(
+ if header_release_candidate_version := os.getenv('release_candidate') is None:
+ header_release_candidate_version = _get_version_from_url(
"https://raw.githubusercontent.com/ROCm/rocm-docs-core/new_data/release_candidate.txt"
)
context["header_release_candidate_version"] = (
header_release_candidate_version
)
- google_site_verification_content = _get_version_from_url(
+ if google_site_verification_content := os.getenv('google_site_verification') is None:
+ google_site_verification_content = _get_version_from_url(
"https://raw.githubusercontent.com/ROCm/rocm-docs-core/data/google_site_verification.txt"
)
context["google_site_verification_content"] = (
@@ -189,11 +193,13 @@ def _update_theme_options(app: Sphinx) -> None:
0, "components/left-side-menu"
)
- header_latest_version = _get_version_from_url(
+ if (header_latest_version := str(os.getenv('rocm_data_versions'))) == '':
+ header_latest_version = _get_version_from_url(
"https://raw.githubusercontent.com/ROCm/rocm-docs-core/new_data/latest_version.txt"
)
- header_release_candidate_version = _get_version_from_url(
+ if header_release_candidate_version := os.getenv('release_candidate') is None:
+ header_release_candidate_version = _get_version_from_url(
"https://raw.githubusercontent.com/ROCm/rocm-docs-core/new_data/release_candidate.txt"
)
|