File: 0004-Merge-Get-data-from-env-and-Add-option-to-skip-theme.patch

package info (click to toggle)
rocm-docs-core 1.23.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,632 kB
  • sloc: python: 1,960; sh: 160; javascript: 152; cpp: 29; makefile: 27
file content (87 lines) | stat: -rw-r--r-- 3,748 bytes parent folder | download
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
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

---
 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 3e01de2..2b7a8ba 100644
--- a/src/rocm_docs/projects.py
+++ b/src/rocm_docs/projects.py
@@ -408,11 +408,17 @@ def _update_theme_configs(
     app: Sphinx, current_project: _Project | None, current_branch: str
 ) -> None:
     """Update configurations for use in theme.py"""
-    latest_version = requests.get(
+    # In case of no internet access
+    if "ROCM_DOCS_SKIP_UPDATE_THEME_CONFIGS" in os.environ:
+        return
+
+    if latest_version := os.getenv('latest_version') is None:
+       latest_version = requests.get(
         "https://raw.githubusercontent.com/ROCm/rocm-docs-core/data/latest_version.txt"
     ).text.strip("\r\n")
     latest_version_string = f"docs-{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/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 2f68fad..b19f249 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__)
 
@@ -48,19 +49,22 @@ def _add_custom_context(
     context: dict[str, str],
     doctree: object,  # noqa: ARG001
 ) -> None:
-    header_latest_version = _get_version_from_url(
+    if header_latest_version := os.getenv('latest_version') is None:
+       header_latest_version = _get_version_from_url(
         "https://raw.githubusercontent.com/ROCm/rocm-docs-core/data/latest_version.txt"
     )
     context["header_latest_version"] = header_latest_version
 
-    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/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"] = (
@@ -158,11 +162,13 @@ def _update_theme_options(app: Sphinx) -> None:
             0, "components/left-side-menu"
         )
 
-    header_latest_version = _get_version_from_url(
+    if header_latest_version := os.getenv('latest_version') is None:
+       header_latest_version = _get_version_from_url(
         "https://raw.githubusercontent.com/ROCm/rocm-docs-core/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/data/release_candidate.txt"
     )