Compare sphinx version using a tuple

This commit is contained in:
Aaron Carlisle 2021-07-13 21:04:16 -04:00
parent 0ef60e7841
commit da20decbbb
2 changed files with 8 additions and 3 deletions

View File

@ -31,6 +31,9 @@ def config_initiated(app, config):
_('The canonical_url option is deprecated, use the html_baseurl option from Sphinx instead.')
)
def page_context_handler(app, pagename, templatename, context, doctree):
"""Expose sphinx version to html templates in a more programatic way."""
context['sphinx_version_tuple'] = sphinx_version
# See http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package
def setup(app):
@ -61,4 +64,6 @@ def setup(app):
else:
app.config.html_add_permalinks = "\uf0c1"
app.connect('html-page-context', page_context_handler)
return {'parallel_read_safe': True, 'parallel_write_safe': True}

View File

@ -20,7 +20,7 @@
{%- endblock -%}
{#- CSS #}
{%- if (sphinx_version < "4.0.0") -%}
{%- if sphinx_version_tuple < (4, 0,) -%}
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
{%- endif %}
@ -58,8 +58,8 @@
<![endif]-->
{%- if not embedded %}
{# XXX Sphinx 1.8.0 made this an external js-file, quick fix until we refactor the template to inherert more blocks directly from sphinx #}
{%- if sphinx_version >= "1.8.0" -%}
{%- if sphinx_version < "4.0.0" -%}
{%- if sphinx_version_tuple >= (1, 8) -%}
{%- if sphinx_version_tuple < (4, 0) -%}
<script id="documentation_options" data-url_root="{{ url_root }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
{%- endif -%}
{%- for scriptfile in script_files %}