Skip to content

Commit 023c4bf

Browse files
authored
CI: Fix the latest docs with more fine-grained warning banners (#411)
* more fine-grained warning banners * fix for local doc builds
1 parent d4a68b8 commit 023c4bf

File tree

5 files changed

+30
-14
lines changed

5 files changed

+30
-14
lines changed

.github/actions/get_pr_number/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ runs:
2121
exit 1
2222
fi
2323
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
24+
echo "BUILD_PREVIEW=1" >> $GITHUB_ENV
2425
2526
- name: Get PR data (main branch)
2627
if: ${{ github.ref_name == 'main' }}
@@ -50,3 +51,4 @@ runs:
5051
exit 1
5152
fi
5253
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
54+
echo "BUILD_LATEST=1" >> $GITHUB_ENV

cuda_bindings/docs/source/conf.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@
7171
# ],
7272
}
7373
if os.environ.get("CI"):
74-
PR_NUMBER = f"{os.environ['PR_NUMBER']}"
75-
PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>'
76-
html_theme_options["announcement"] = f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!"
74+
if int(os.environ.get("BUILD_PREVIEW", 0)):
75+
PR_NUMBER = f"{os.environ['PR_NUMBER']}"
76+
PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>'
77+
html_theme_options["announcement"] = f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!"
78+
elif int(os.environ.get("BUILD_LATEST", 0)):
79+
html_theme_options["announcement"] = (
80+
"<em>Warning</em>: This documentation is built from the development branch!"
81+
)
7782

7883
# Add any paths that contain custom static files (such as style sheets) here,
7984
# relative to this directory. They are copied after the builtin static files,

cuda_core/docs/source/conf.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,14 @@
7676
# ],
7777
}
7878
if os.environ.get("CI"):
79-
PR_NUMBER = f"{os.environ['PR_NUMBER']}"
80-
PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>'
81-
html_theme_options["announcement"] = f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!"
79+
if int(os.environ.get("BUILD_PREVIEW", 0)):
80+
PR_NUMBER = f"{os.environ['PR_NUMBER']}"
81+
PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>'
82+
html_theme_options["announcement"] = f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!"
83+
elif int(os.environ.get("BUILD_LATEST", 0)):
84+
html_theme_options["announcement"] = (
85+
"<em>Warning</em>: This documentation is built from the development branch!"
86+
)
8287

8388
# Add any paths that contain custom static files (such as style sheets) here,
8489
# relative to this directory. They are copied after the builtin static files,

cuda_python/docs/source/conf.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@
7272
# ],
7373
}
7474
if os.environ.get("CI"):
75-
PR_NUMBER = f"{os.environ['PR_NUMBER']}"
76-
PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>'
77-
html_theme_options["announcement"] = (
78-
f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!"
79-
)
75+
if int(os.environ.get("BUILD_PREVIEW", 0)):
76+
PR_NUMBER = f"{os.environ['PR_NUMBER']}"
77+
PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>'
78+
html_theme_options["announcement"] = f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!"
79+
elif int(os.environ.get("BUILD_LATEST", 0)):
80+
html_theme_options["announcement"] = (
81+
"<em>Warning</em>: This documentation is built from the development branch!"
82+
)
8083

8184
# Add any paths that contain custom static files (such as style sheets) here,
8285
# relative to this directory. They are copied after the builtin static files,
@@ -86,9 +89,7 @@
8689
# Allow overwriting CUDA Python's domain name for local development. See:
8790
# - https://stackoverflow.com/a/61694897/2344149
8891
# - https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-rst_epilog
89-
CUDA_PYTHON_DOMAIN = os.environ.get(
90-
"CUDA_PYTHON_DOMAIN", "https://nvidia.github.io/cuda-python"
91-
)
92+
CUDA_PYTHON_DOMAIN = os.environ.get("CUDA_PYTHON_DOMAIN", "https://nvidia.github.io/cuda-python")
9293
rst_epilog = f"""
9394
.. _cuda.core: {CUDA_PYTHON_DOMAIN}/cuda-core/latest
9495
.. _cuda.bindings: {CUDA_PYTHON_DOMAIN}/cuda-bindings/latest

cuda_python/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ homepage = "https://nvidia.github.io/cuda-python/"
3939
documentation = "https://nvidia.github.io/cuda-python/"
4040
repository = "https://github.com/NVIDIA/cuda-python/"
4141
issues = "https://github.com/NVIDIA/cuda-python/issues/"
42+
43+
[tool.ruff]
44+
line-length = 120

0 commit comments

Comments
 (0)