Skip to content

Commit 06ff8ec

Browse files
committed
doc: add version switcher flyout
Backport the bottom-left version switcher from unstable. Overrides the empty versions.html shipped by sphinx_rtd_theme 3.x with _templates/versions.html and populates html_context['versions']; styled by the theme CSS, toggled by theme.js.
1 parent 006f626 commit 06ff8ec

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

doc/_templates/versions.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{# Version switcher flyout.
2+
3+
sphinx_rtd_theme 3.x ships an empty versions.html (the flyout is injected by
4+
the ReadTheDocs addons when hosted there, and is absent on self-hosted
5+
builds). layout.html still does `{% include "versions.html" %}`, so this
6+
override revives the classic bottom-left "v: <version> ▾" widget. It is
7+
styled by the theme's existing .rst-versions CSS and toggled by theme.js;
8+
the entries come from html_context['versions'] in conf.py. #}
9+
{%- if versions %}
10+
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="{{ _('Versions') }}">
11+
<span class="rst-current-version" data-toggle="rst-current-version">
12+
<span class="fa fa-book"> {{ _('Versions') }}</span>
13+
v: {{ current_version }}
14+
<span class="fa fa-caret-down"></span>
15+
</span>
16+
<div class="rst-other-versions">
17+
<dl>
18+
<dt>{{ _('Versions') }}</dt>
19+
{%- for slug, url in versions %}
20+
<dd><a href="{{ url }}">{{ slug }}</a></dd>
21+
{%- endfor %}
22+
</dl>
23+
</div>
24+
</div>
25+
{%- endif %}

doc/conf.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,22 @@
8888

8989
html_show_sphinx = True
9090
nbsphinx_allow_errors = True
91-
html_context = {'header_title': '@PROJECT_NAME@'}
91+
html_context = {
92+
'header_title': '@PROJECT_NAME@',
93+
# Version switcher flyout (rendered by _templates/versions.html, which
94+
# overrides the empty versions.html shipped by sphinx_rtd_theme 3.x). The
95+
# list is static -- update it when a new release line is published.
96+
# display_lower_left enables the flyout on older theme versions that gate
97+
# the include on it; harmless on 3.x.
98+
'display_lower_left': True,
99+
'current_version': version,
100+
'versions': [
101+
['latest', 'https://triqs.github.io/solid_dmft/latest/'],
102+
['unstable', 'https://triqs.github.io/solid_dmft/unstable/'],
103+
['4.0.x', 'https://triqs.github.io/solid_dmft/4.0.x/'],
104+
['3.3.x', 'https://triqs.github.io/solid_dmft/3.3.x/'],
105+
],
106+
}
92107
html_static_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_static']
93108
html_sidebars = {'index': ['sideb.html', 'searchbox.html']}
94109

0 commit comments

Comments
 (0)