mirror of
https://github.com/readthedocs/sphinx_rtd_theme.git
synced 2025-02-25 18:55:21 -06:00
Remove Sphinx<5 compatibility leftovers (#1512)
* Remove Sphinx<5 compatibility
Since 2.0 we do not support Sphinx<5.
* Always use `writer-html5`
Since 2.0 HTML4 writer is not supported.
* Use `css_tag` helper to inject CSS files
* Revert "Remove Sphinx<5 compatibility"
Keep `sphinx_version_info`. It will be required.
This reverts commit 3afbed2950.
* Set `data-content_root` for Sphinx >= 7.2
Copied from https://github.com/readthedocs/sphinx_rtd_theme/pull/1507
* Default value for `DISPLAY` and `--new-tab`
* Visual test with Firefox and tox
Allows developer to run
```
tox -e py310-sphinx72-firefox
```
This will run the tests and open a Firefox after building the demo site
showing the `demo/demo.html` page on it.
Then, you can also run:
```
tox -e py310-sphinx61-firefox
```
and compare the visual differences.
Idea copied from #1388
Closes #1388
* Update sphinx_rtd_theme/layout.html
Co-authored-by: Dmitry Shachnev <mitya57@users.noreply.github.com>
* Remove code from merge conflict
* Revert a mistake done on merging
* Update CSS logic again
* Minor refactor to undocumented `extra_css_files` option
---------
Co-authored-by: Dmitry Shachnev <mitya57@users.noreply.github.com>
This commit is contained in:
@@ -7,14 +7,13 @@
|
||||
{%- set titlesuffix = "" %}
|
||||
{%- endif %}
|
||||
{%- 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 }}"{% if sphinx_version_info >= (7, 2) %} data-content_root="{{ content_root }}"{% endif %}>
|
||||
<html class="writer-html5" lang="{{ lang_attr }}"{% if sphinx_version_info >= (7, 2) %} data-content_root="{{ content_root }}"{% endif %}>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
{{- metatags }}
|
||||
@@ -24,10 +23,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_file in css_files %}
|
||||
{%- if css_file|attr("filename") %}
|
||||
{{ css_tag(css_file) }}
|
||||
@@ -36,18 +31,19 @@
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
{# "extra_css_files" is a theme option and it's always a string #}
|
||||
{#
|
||||
"extra_css_files" is an undocumented Read the Docs theme specific option.
|
||||
There is no need to check for ``|attr("filename")`` here because it's always a string.
|
||||
Note that this option should be removed in favor of regular ``html_css_files``:
|
||||
https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_css_files
|
||||
#}
|
||||
{%- for css_file in extra_css_files %}
|
||||
<link rel="stylesheet" href="{{ pathto(css_file, 1)|escape }}" 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) #}
|
||||
@@ -66,30 +62,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 #}
|
||||
|
||||
Reference in New Issue
Block a user