Skip to content

Commit

Permalink
Remove Sphinx<5 compatibility
Browse files Browse the repository at this point in the history
Since 2.0 we do not support Sphinx<5.
  • Loading branch information
humitos committed Aug 23, 2023
1 parent 923f987 commit 3afbed2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 46 deletions.
8 changes: 0 additions & 8 deletions sphinx_rtd_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ def config_initiated(app, config):
)


def extend_html_context(app, pagename, templatename, context, doctree):

This comment has been minimized.

Copy link
@Md0135

Md0135 Jan 15, 2024

ÖD

# 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:
Expand Down Expand Up @@ -71,7 +66,4 @@ def setup(app):
# sphinx emits the permalink icon for headers, so choose one more in keeping with our theme
app.config.html_permalinks_icon = "\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}
44 changes: 6 additions & 38 deletions sphinx_rtd_theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +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) = (sphinx_version.split('.') | list)[:2] | map('int') -%}
{%- set sphinx_version_info = (_ver_major, _ver_minor, -1) -%}

<!DOCTYPE html>
<html class="{{ sphinx_writer }}" lang="{{ lang_attr }}" >
Expand All @@ -24,10 +21,6 @@
{%- endblock -%}

{#- CSS #}
{%- if sphinx_version_info < (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 %}
{%- for css in css_files %}
{%- if css|attr("rel") %}
<link rel="{{ css.rel }}" href="{{ pathto(css.filename, 1) }}" type="text/css"{% if css.title is not none %} title="{{ css.title }}"{% endif %} />
Expand All @@ -40,13 +33,9 @@
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
{%- endfor -%}

{#- FAVICON
favicon_url is the only context var necessary since Sphinx 4.
In Sphinx<4, we use favicon but need to prepend path info.
#}
{%- set _favicon_url = favicon_url | default(pathto('_static/' + (favicon or ""), 1)) %}
{%- if favicon_url or favicon %}
<link rel="shortcut icon" href="{{ _favicon_url }}"/>
{#- FAVICON #}
{%- if favicon_url %}
<link rel="shortcut icon" href="{{ favicon_url }}"/>
{%- endif %}

{#- CANONICAL URL (deprecated) #}
Expand All @@ -65,30 +54,9 @@
<script src="{{ pathto('_static/js/html5shiv.min.js', 1) }}"></script>
<![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_info >= (1, 8) -%}
{%- if sphinx_version_info < (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 %}
{{ js_tag(scriptfile) }}
{%- endfor %}
{%- else %}
<script>
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'{{ url_root }}',
VERSION:'{{ release|e }}',
LANGUAGE:'{{ language }}',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}',
HAS_SOURCE: {{ has_source|lower }},
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}'
};
</script>
{%- for scriptfile in script_files %}
<script src="{{ pathto(scriptfile, 1) }}"></script>
{%- endfor %}
{%- endif %}
{%- for scriptfile in script_files %}
{{ js_tag(scriptfile) }}
{%- endfor %}
<script src="{{ pathto('_static/js/theme.js', 1) }}"></script>

{#- OPENSEARCH #}
Expand Down

2 comments on commit 3afbed2

@Md0135
Copy link

@Md0135 Md0135 commented on 3afbed2 Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

``

@Md0135
Copy link

@Md0135 Md0135 commented on 3afbed2 Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MD

Please sign in to comment.