Skip to content

Commit 3aad688

Browse files
author
Diptorup Deb
committed
Add support for mult-version links in side-bar.
1 parent 18275b2 commit 3aad688

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

docs/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ option(DPCTL_ENABLE_DOXYREST
77
OFF
88
)
99

10+
# Option to add verion links to the side bar. This option is primarily
11+
# intended to generate dpctl's docs for our github.io page.
12+
option(DPCTL_USE_MULTIVERSION_TEMPLATE
13+
"Enable adding verion links to side bar"
14+
OFF
15+
)
16+
1017
# This function defines everything needed to generate Doxygen docs
1118
function(_setup_doxygen)
1219
# We generate doxygen only for the public headers to keep the Doxyrest

docs/_templates/versions.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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>
22+
{% endif %}

docs/conf.in

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,44 @@ html_theme_options = {
9898
# relative to this directory. They are copied after the builtin static files,
9999
# so a file named "default.css" will overwrite the builtin "default.css".
100100
# html_static_path = ['_static']
101+
102+
# When the cmake DPCTL_USE_MULTIVERSION_TEMPLATE flag is set we generate
103+
# links in the sidebar to the documentation for older versions of dpctl.
104+
# Note that ths option does not actually generate the documentation for
105+
# older versions, it only adds links in the sidebar to earlier versions of
106+
# the documentation. All earlier versions of the documentation should be
107+
# generated and pushed to the gh-pages branch manually, after which the
108+
# doc_versions.txt should be updated.
109+
110+
generate_multiversion = "@DPCTL_USE_MULTIVERSION_TEMPLATE@"
111+
112+
if generate_multiversion == "ON":
113+
try:
114+
html_context
115+
except NameError:
116+
html_context = dict()
117+
html_context["display_lower_left"] = True
118+
templates_path = ["_templates"]
119+
html_context["current_version"] = version
120+
html_context["version"] = version
121+
122+
# POPULATE LINKS TO OTHER VERSIONS
123+
html_context["versions"] = list()
124+
125+
# Populate the list of documented versions from the doc_versions.tx
126+
versions = []
127+
with open("doc_versions.txt", "r") as doc_versions:
128+
while True:
129+
version = doc_versions.readline().strip()
130+
if not version:
131+
break
132+
elif len(version):
133+
versions.append(version)
134+
135+
# FIXME: Remove this hard coding
136+
DOC_SITE_NAME = "https://intelpython.github.io/dpctl/"
137+
138+
for version in versions:
139+
html_context["versions"].append(
140+
(version, DOC_SITE_NAME + version + "/index.html")
141+
)

docs/doc_versions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0.6.1
2+
latest

0 commit comments

Comments
 (0)