Skip to content

Commit

Permalink
more fine-grained warning banners
Browse files Browse the repository at this point in the history
  • Loading branch information
leofang committed Jan 20, 2025
1 parent d4a68b8 commit 2d6bbc3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/actions/get_pr_number/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ runs:
exit 1
fi
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
echo "BUILD_PREVIEW=1" >> $GITHUB_ENV
- name: Get PR data (main branch)
if: ${{ github.ref_name == 'main' }}
Expand Down Expand Up @@ -50,3 +51,4 @@ runs:
exit 1
fi
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
echo "BUILD_LATEST=1" >> $GITHUB_ENV
11 changes: 8 additions & 3 deletions cuda_bindings/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@
# ],
}
if os.environ.get("CI"):
PR_NUMBER = f"{os.environ['PR_NUMBER']}"
PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>'
html_theme_options["announcement"] = f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!"
if int(os.environ.get("BUILD_PREVIEW")):
PR_NUMBER = f"{os.environ['PR_NUMBER']}"
PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>'
html_theme_options["announcement"] = f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!"
elif int(os.environ.get("BUILD_LATEST")):
html_theme_options["announcement"] = (
"<em>Warning</em>: This documentation is built from the development branch!"
)

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down
11 changes: 8 additions & 3 deletions cuda_core/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,14 @@
# ],
}
if os.environ.get("CI"):
PR_NUMBER = f"{os.environ['PR_NUMBER']}"
PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>'
html_theme_options["announcement"] = f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!"
if int(os.environ.get("BUILD_PREVIEW")):
PR_NUMBER = f"{os.environ['PR_NUMBER']}"
PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>'
html_theme_options["announcement"] = f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!"
elif int(os.environ.get("BUILD_LATEST")):
html_theme_options["announcement"] = (
"<em>Warning</em>: This documentation is built from the development branch!"
)

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down
17 changes: 9 additions & 8 deletions cuda_python/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@
# ],
}
if os.environ.get("CI"):
PR_NUMBER = f"{os.environ['PR_NUMBER']}"
PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>'
html_theme_options["announcement"] = (
f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!"
)
if int(os.environ.get("BUILD_PREVIEW")):
PR_NUMBER = f"{os.environ['PR_NUMBER']}"
PR_TEXT = f'<a href="https://github.com/NVIDIA/cuda-python/pull/{PR_NUMBER}">PR {PR_NUMBER}</a>'
html_theme_options["announcement"] = f"<em>Warning</em>: This documentation is only a preview for {PR_TEXT}!"
elif int(os.environ.get("BUILD_LATEST")):
html_theme_options["announcement"] = (
"<em>Warning</em>: This documentation is built from the development branch!"
)

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand All @@ -86,9 +89,7 @@
# Allow overwriting CUDA Python's domain name for local development. See:
# - https://stackoverflow.com/a/61694897/2344149
# - https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-rst_epilog
CUDA_PYTHON_DOMAIN = os.environ.get(
"CUDA_PYTHON_DOMAIN", "https://nvidia.github.io/cuda-python"
)
CUDA_PYTHON_DOMAIN = os.environ.get("CUDA_PYTHON_DOMAIN", "https://nvidia.github.io/cuda-python")
rst_epilog = f"""
.. _cuda.core: {CUDA_PYTHON_DOMAIN}/cuda-core/latest
.. _cuda.bindings: {CUDA_PYTHON_DOMAIN}/cuda-bindings/latest
Expand Down
3 changes: 3 additions & 0 deletions cuda_python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ homepage = "https://nvidia.github.io/cuda-python/"
documentation = "https://nvidia.github.io/cuda-python/"
repository = "https://github.com/NVIDIA/cuda-python/"
issues = "https://github.com/NVIDIA/cuda-python/issues/"

[tool.ruff]
line-length = 120

0 comments on commit 2d6bbc3

Please sign in to comment.