Skip to content

Commit 3110434

Browse files
committed
Override versions.html template for specific RTD functionality
Sphinx RTD theme uses a `versions.html` template to generate the version menu if `READTHEDOCS` variable is True. Since this is something specific to Read the Docs and that variable is going to be removed soon from the theme, we are overriding this template to maintain our current functionality. Also, the static content generated in this menu is removed to avoid showing invalid links/data in case the AJAX fails for any reason. If this happen, the menu just won't show any information.
1 parent 04ce7bb commit 3110434

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ if 'html_context' in globals():
132132
else:
133133
html_context = context
134134

135+
# Add custom RTD templates
136+
if 'templates_path' in globals():
137+
templates_path.append('{{ template_path }}')
138+
else:
139+
templates_path = [
140+
'{{ template_path }}',
141+
]
142+
135143
# Add custom RTD extension
136144
if 'extensions' in globals():
137145
# Insert at the beginning because it can interfere
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{# Template override to avoid adding static version menu into Read the Docs production sites #}
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"> Read the Docs</span>
6+
v: {{ current_version }}
7+
<span class="fa fa-caret-down"></span>
8+
</span>
9+
<div class="rst-other-versions">
10+
{# This content is injected by an AJAX call to readthedocs.org/readthedocs.com #}
11+
</div>
12+
</div>

0 commit comments

Comments
 (0)