Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/readthedocs/sphinx_rtd_theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Elson <pelson.pub@gmail.com>2022-10-04 00:12:51 +0300
committerGitHub <noreply@github.com>2022-10-04 00:12:51 +0300
commit45cf21874fb005ac86206ed26f609cb509eebbb2 (patch)
tree8133716f6083e29147d71e4e5e2b8be46d148fce
parent855e89ba52ef48a23babe3463368c42cd8fd81dc (diff)
Update layout.html to support a sphinx version that is not three-integers (#1345)
* Update layout.html to support a sphinx version that is not three-integers. Useful for sphinx==5.2.0.post0 * Apply suggestions from code review Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> * No reason to only have the first three elements from the sphinx version Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Benjamin Balder Bach <benjamin@overtag.dk>
-rw-r--r--sphinx_rtd_theme/__init__.py9
-rw-r--r--sphinx_rtd_theme/layout.html4
2 files changed, 9 insertions, 4 deletions
diff --git a/sphinx_rtd_theme/__init__.py b/sphinx_rtd_theme/__init__.py
index f319098..9ea323f 100644
--- a/sphinx_rtd_theme/__init__.py
+++ b/sphinx_rtd_theme/__init__.py
@@ -31,6 +31,12 @@ def config_initiated(app, config):
_('The canonical_url option is deprecated, use the html_baseurl option from Sphinx instead.')
)
+
+def extend_html_context(app, pagename, templatename, context, doctree):
+ # Add ``sphinx_version_info`` tuple for use in Jinja templates
+ context['sphinx_version_info'] = sphinx_version
+
+
# See http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package
def setup(app):
if python_version[0] < 3:
@@ -60,4 +66,7 @@ def setup(app):
else:
app.config.html_add_permalinks = "\uf0c1"
+ # Extend the default context when rendering the templates.
+ app.connect("html-page-context", extend_html_context)
+
return {'parallel_read_safe': True, 'parallel_write_safe': True}
diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html
index 1d70119..99ec01b 100644
--- a/sphinx_rtd_theme/layout.html
+++ b/sphinx_rtd_theme/layout.html
@@ -9,10 +9,6 @@
{%- set lang_attr = 'en' if language == None else (language | replace('_', '-')) %}
{%- set sphinx_writer = 'writer-html5' if html5_doctype else 'writer-html4' -%}
-{# Build sphinx_version_info tuple from sphinx_version string in pure Jinja #}
-{%- set (_ver_major, _ver_minor, _ver_bugfix) = sphinx_version.split('.') | map('int') -%}
-{%- set sphinx_version_info = (_ver_major, _ver_minor, _ver_bugfix) -%}
-
<!DOCTYPE html>
<html class="{{ sphinx_writer }}" lang="{{ lang_attr }}" >
<head>