From 7687fcf6cdc7d064ec136def4b48e4710407b726 Mon Sep 17 00:00:00 2001 From: Michael Altfield Date: Thu, 23 Jul 2020 14:48:29 +0545 Subject: [PATCH] improving usability of lower-left rtd menu This commit makes several changes to the rtd theme's version.html template such that the lower-left rtd menu now has: 1. Support to display nav links to alternate languages by defining them as a list of tuples (just like versions and downloads) 2. Adds a new variable 'display_lower_left' so that the lower-left menu can be toggled independently, while the "On Read the Docs" section is toggled with the READTHEDOCS boolean. 3. Adds a conditional to the 'versions' section to display the current version in bold (same as readthedocs.io does) 4. Add a conditional to the 'downloads' section to only display the downloads section if there's a non-empty downloads list For more information about this change, see: * https://tech.michaelaltfield.net/2020/07/23/sphinx-rtd-github-pages-2/ --- sphinx_rtd_theme/versions.html | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sphinx_rtd_theme/versions.html b/sphinx_rtd_theme/versions.html index 7368659c4..7452ea291 100644 --- a/sphinx_rtd_theme/versions.html +++ b/sphinx_rtd_theme/versions.html @@ -1,4 +1,4 @@ -{% if READTHEDOCS %} +{% if READTHEDOCS or display_lower_left %} {# Add rst-badge after rst-versions for small badge style. #}
@@ -7,18 +7,35 @@
+ {% if languages|length >= 1 %} +
+
{{ _('Languages') }}
+ {% for slug, url in languages %} + {% if slug == current_language %} {% endif %} +
{{ slug }}
+ {% if slug == current_language %}
{% endif %} + {% endfor %} +
+ {% endif %} + {% if versions|length >= 1 %}
{{ _('Versions') }}
{% for slug, url in versions %} + {% if slug == current_version %} {% endif %}
{{ slug }}
+ {% if slug == current_version %}
{% endif %} {% endfor %}
+ {% endif %} + {% if downloads|length >= 1 %}
{{ _('Downloads') }}
{% for type, url in downloads %}
{{ type }}
{% endfor %}
+ {% endif %} + {% if READTHEDOCS %}
{# Translators: The phrase "Read the Docs" is not translated #}
{{ _('On Read the Docs') }}
@@ -29,6 +46,7 @@ {{ _('Builds') }}
+ {% endif %}
{% endif %}