Skip to content

Commit 8e5a64d

Browse files
authored
Merge pull request #2276 from IntelPython/enable-versioned-documentation
Enable versioned documentation
2 parents 8b5e3b6 + c246294 commit 8e5a64d

6 files changed

Lines changed: 48 additions & 32 deletions

File tree

.github/workflows/generate-docs.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,10 @@ jobs:
7575
source /opt/intel/oneapi/setvars.sh
7676
wget https://github.com/vovkos/doxyrest/releases/download/doxyrest-2.1.2/doxyrest-2.1.2-linux-amd64.tar.xz
7777
tar xf doxyrest-2.1.2-linux-amd64.tar.xz
78-
python scripts/gen_docs.py --doxyrest-root=`pwd`/doxyrest-2.1.2-linux-amd64 --verbose || exit 1
78+
python scripts/gen_docs.py --doxyrest-root=`pwd`/doxyrest-2.1.2-linux-amd64 --verbose --multiversion --clean || exit 1
7979
python -c "import dpctl; print(dpctl.__version__)" || exit 1
80-
pushd "$(find _skbuild -name cmake-build)" || exit 1
81-
cmake --build . --target Sphinx || exit 1
82-
mv ../cmake-install/docs/docs ~/docs
80+
mv "$(find _skbuild -type d -path "*/cmake-install/docs/docs" | head -n 1)" ~/docs
8381
git clean -dfx
84-
popd
8582
git reset --hard
8683
- name: Publish docs
8784
if: ${{ !github.event.pull_request && github.ref == 'refs/heads/master' }}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Maintenance
1818

19+
* Enabled multiversion documentation for `dpctl` using a custom drop-down for version selection and a `--multiversion` option for documentation build helper script [gh-2276](https://github.com/IntelPython/dpctl/pull/2276)
20+
1921
## [0.21.1] - Nov. 29, 2025
2022

2123
This release is made to distribute `dpctl` for Python 3.14. Only the non-free-threaded version of Python is supported as of this release.
Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
{% if READTHEDOCS or display_lower_left %}
2-
{# Add rst-badge after rst-versions for small badge style. #}
3-
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
4-
<span class="rst-current-version" data-toggle="rst-current-version">
5-
<span class="fa fa-book"> Other versions</span>
6-
v: {{ current_version }}
7-
<span class="fa fa-caret-down"></span>
8-
</span>
9-
<div class="rst-other-versions">
10-
{% if versions|length >= 1 %}
11-
<dl>
12-
<dt>{{ _('Versions') }}</dt>
13-
{% for slug, url in versions %}
14-
{% if slug == current_version %} <strong> {% endif %}
15-
<dd><a href="{{ url }}">{{ slug }}</a></dd>
16-
{% if slug == current_version %} </strong> {% endif %}
17-
{% endfor %}
18-
</dl>
19-
{% endif %}
20-
</div>
21-
</div>
1+
{% if display_lower_left %}
2+
<div class="sidebar-versions" style="padding: 1em; border-top: 1px solid var (--color-sidebar-brand-text);">
3+
<strong>Docs Version</strong>
4+
<select onchange="window.location.href=this.value" style="width: 100%; margin-top: 0.5em; padding: 0.25em;">
5+
{% for slug, url in versions %}
6+
<option value="{{ url }}" {% if slug==current_version %}selected{% endif %}>
7+
{{ slug }}
8+
</option>
9+
{% endfor %}
10+
</select>
11+
</div>
2212
{% endif %}

docs/doc_sources/conf.py.in

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,18 @@ if generate_multiversion == "ON":
137137
html_context = dict()
138138
html_context["display_lower_left"] = True
139139
templates_path = ["_templates"]
140-
html_context["current_version"] = version
140+
html_context["current_version"] = release
141141
html_context["version"] = version
142142

143143
# POPULATE LINKS TO OTHER VERSIONS
144144
html_context["versions"] = list()
145145

146-
# Populate the list of documented versions from the doc_versions.tx
146+
# Populate the list of documented versions from the doc_versions.txt
147147
versions = []
148-
with open("doc_versions.txt", "r") as doc_versions:
148+
149+
conf_dir = os.path.dirname(os.path.abspath(__file__))
150+
versions_file = os.path.join(conf_dir, "..", "doc_versions.txt")
151+
with open(versions_file, "r") as doc_versions:
149152
while True:
150153
version = doc_versions.readline().strip()
151154
if not version:
@@ -160,3 +163,19 @@ if generate_multiversion == "ON":
160163
html_context["versions"].append(
161164
(version, DOC_SITE_NAME + version + "/index.html")
162165
)
166+
167+
if html_context["current_version"] not in versions:
168+
html_context["current_version"] = "latest"
169+
170+
# override furo sidebar when multiversion is on to add the version dropdown
171+
html_sidebars = {
172+
"**": [
173+
"sidebar/scroll-start.html",
174+
"sidebar/brand.html",
175+
"sidebar/search.html",
176+
"versions.html",
177+
"sidebar/navigation.html",
178+
"sidebar/ethical-ads.html",
179+
"sidebar/scroll-end.html",
180+
]
181+
}

docs/doc_versions.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
0.8.0
2-
0.7.0
3-
0.6.1
41
latest
2+
0.21.1
3+
0.21.0

scripts/gen_docs.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ def parse_args():
9595
),
9696
)
9797

98+
p.add_argument(
99+
"--multiversion",
100+
action="store_true",
101+
help="Enable multiversion sidebar links in docs (default: False)",
102+
)
103+
98104
p.add_argument(
99105
"--clean",
100106
action="store_true",
@@ -137,6 +143,9 @@ def main():
137143
cmake_args += ["-DDPCTL_ENABLE_DOXYREST=ON"]
138144
cmake_args += [f"-DDoxyrest_DIR={args.doxyrest_root}"]
139145

146+
if args.multiversion:
147+
cmake_args += ["-DDPCTL_USE_MULTIVERSION_TEMPLATE=ON"]
148+
140149
log_cmake_args(cmake_args, "gen_docs")
141150

142151
env = os.environ.copy()

0 commit comments

Comments
 (0)