|
7 | 7 | {%- set titlesuffix = "" %}
|
8 | 8 | {%- endif %}
|
9 | 9 | {%- set lang_attr = 'en' if language == None else (language | replace('_', '-')) %}
|
10 |
| -{%- set sphinx_writer = 'writer-html5' if html5_doctype else 'writer-html4' -%} |
11 | 10 |
|
12 | 11 | {# Build sphinx_version_info tuple from sphinx_version string in pure Jinja #}
|
13 |
| -{%- set (_ver_major, _ver_minor, _ver_bugfix) = sphinx_version.split('.') | map('int') -%} |
14 |
| -{%- set sphinx_version_info = (_ver_major, _ver_minor, _ver_bugfix) -%} |
| 12 | +{%- set (_ver_major, _ver_minor) = (sphinx_version.split('.') | list)[:2] | map('int') -%} |
| 13 | +{%- set sphinx_version_info = (_ver_major, _ver_minor, -1) -%} |
15 | 14 |
|
16 | 15 | <!DOCTYPE html>
|
17 |
| -<html class="{{ sphinx_writer }}" lang="{{ lang_attr }}" > |
| 16 | +<html class="writer-html5" lang="{{ lang_attr }}"{% if sphinx_version_info >= (7, 2) %} data-content_root="{{ content_root }}"{% endif %}> |
18 | 17 | <head>
|
19 | 18 | <meta charset="utf-8" />
|
20 | 19 | {{- metatags }}
|
|
24 | 23 | {%- endblock -%}
|
25 | 24 |
|
26 | 25 | {#- CSS #}
|
27 |
| - {%- if sphinx_version_info < (4, 0) -%} |
28 |
| - <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" /> |
29 |
| - <link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" /> |
30 |
| - {%- endif %} |
31 |
| - {%- for css in css_files %} |
32 |
| - {%- if css|attr("rel") %} |
33 |
| - <link rel="{{ css.rel }}" href="{{ pathto(css.filename, 1) }}" type="text/css"{% if css.title is not none %} title="{{ css.title }}"{% endif %} /> |
| 26 | + {%- for css_file in css_files %} |
| 27 | + {%- if css_file|attr("filename") %} |
| 28 | + {{ css_tag(css_file) }} |
34 | 29 | {%- else %}
|
35 |
| - <link rel="stylesheet" href="{{ pathto(css, 1) }}" type="text/css" /> |
| 30 | + <link rel="stylesheet" href="{{ pathto(css_file, 1)|escape }}" type="text/css" /> |
36 | 31 | {%- endif %}
|
37 | 32 | {%- endfor %}
|
38 | 33 |
|
39 |
| - {%- for cssfile in extra_css_files %} |
40 |
| - <link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" /> |
| 34 | + {# |
| 35 | + "extra_css_files" is an undocumented Read the Docs theme specific option. |
| 36 | + There is no need to check for ``|attr("filename")`` here because it's always a string. |
| 37 | + Note that this option should be removed in favor of regular ``html_css_files``: |
| 38 | + https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_css_files |
| 39 | + #} |
| 40 | + {%- for css_file in extra_css_files %} |
| 41 | + <link rel="stylesheet" href="{{ pathto(css_file, 1)|escape }}" type="text/css" /> |
41 | 42 | {%- endfor -%}
|
42 | 43 |
|
43 | 44 | {#- FAVICON #}
|
44 |
| - {%- if favicon %} |
45 |
| - {%- if sphinx_version_info < (4, 0) -%} |
46 |
| - <link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/> |
47 |
| - {%- else %} |
| 45 | + {%- if favicon_url %} |
48 | 46 | <link rel="shortcut icon" href="{{ favicon_url }}"/>
|
49 |
| - {%- endif %} |
50 |
| - {%- endif -%} |
| 47 | + {%- endif %} |
51 | 48 |
|
52 | 49 | {#- CANONICAL URL (deprecated) #}
|
53 | 50 | {%- if theme_canonical_url and not pageurl %}
|
|
61 | 58 |
|
62 | 59 | {#- JAVASCRIPTS #}
|
63 | 60 | {%- block scripts %}
|
64 |
| - <!--[if lt IE 9]> |
65 |
| - <script src="{{ pathto('_static/js/html5shiv.min.js', 1) }}"></script> |
66 |
| - <![endif]--> |
67 | 61 | {%- if not embedded %}
|
68 |
| - {# 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 #} |
69 |
| - {%- if sphinx_version_info >= (1, 8) -%} |
70 |
| - {%- if sphinx_version_info < (4, 0) -%} |
71 |
| - <script id="documentation_options" data-url_root="{{ url_root }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script> |
72 |
| - {%- endif -%} |
73 |
| - {%- for scriptfile in script_files %} |
74 |
| - {{ js_tag(scriptfile) }} |
75 |
| - {%- endfor %} |
76 |
| - {%- else %} |
77 |
| - <script> |
78 |
| - var DOCUMENTATION_OPTIONS = { |
79 |
| - URL_ROOT:'{{ url_root }}', |
80 |
| - VERSION:'{{ release|e }}', |
81 |
| - LANGUAGE:'{{ language }}', |
82 |
| - COLLAPSE_INDEX:false, |
83 |
| - FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}', |
84 |
| - HAS_SOURCE: {{ has_source|lower }}, |
85 |
| - SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}' |
86 |
| - }; |
87 |
| - </script> |
88 |
| - {%- for scriptfile in script_files %} |
89 |
| - <script src="{{ pathto(scriptfile, 1) }}"></script> |
90 |
| - {%- endfor %} |
91 |
| - {%- endif %} |
| 62 | + {%- for scriptfile in script_files %} |
| 63 | + {{ js_tag(scriptfile) }} |
| 64 | + {%- endfor %} |
92 | 65 | <script src="{{ pathto('_static/js/theme.js', 1) }}"></script>
|
93 | 66 |
|
94 | 67 | {#- OPENSEARCH #}
|
|
133 | 106 | <div class="wy-side-nav-search" {% if theme_style_nav_header_background %} style="background: {{theme_style_nav_header_background}}" {% endif %}>
|
134 | 107 | {%- block sidebartitle %}
|
135 | 108 |
|
136 |
| - {%- if logo and theme_logo_only %} |
137 |
| - <a href="{{ pathto(master_doc) }}"> |
138 |
| - {%- else %} |
139 |
| - <a href="{{ pathto(master_doc) }}" class="icon icon-home"> {{ project }} |
140 |
| - {%- endif %} |
141 |
| - |
142 |
| - {%- if logo %} |
143 |
| - {#- Not strictly valid HTML, but it's the only way to display/scale |
144 |
| - it properly, without weird scripting or heaps of work |
145 |
| - #} |
146 |
| - {%- if sphinx_version_info < (4, 0) -%} |
147 |
| - <img src="{{ pathto('_static/' + logo, 1) }}" class="logo" alt="{{ _('Logo') }}"/> |
148 |
| - {%- else %} |
149 |
| - <img src="{{ logo_url }}" class="logo" alt="{{ _('Logo') }}"/> |
| 109 | + {# the logo helper function was removed in Sphinx 6 and deprecated since Sphinx 4 #} |
| 110 | + {# the master_doc variable was renamed to root_doc in Sphinx 4 (master_doc still exists in later Sphinx versions) #} |
| 111 | + {%- set _logo_url = logo_url|default(pathto('_static/' + (logo or ""), 1)) %} |
| 112 | + {%- set _root_doc = root_doc|default(master_doc) %} |
| 113 | + <a href="{{ pathto(_root_doc) }}"{% if not theme_logo_only %} class="icon icon-home"{% endif %}> |
| 114 | + {% if not theme_logo_only %}{{ project }}{% endif %} |
| 115 | + {%- if logo or logo_url %} |
| 116 | + <img src="{{ _logo_url }}" class="logo" alt="{{ _('Logo') }}"/> |
150 | 117 | {%- endif %}
|
151 |
| - {%- endif %} |
152 | 118 | </a>
|
153 | 119 |
|
154 | 120 | {%- if theme_display_version %}
|
|
0 commit comments