Skip to content

Commit c6bb27c

Browse files
committed
Add darkreader
1 parent e8fea4e commit c6bb27c

File tree

1 file changed

+130
-117
lines changed

1 file changed

+130
-117
lines changed

docs/source/_templates/layout.html

Lines changed: 130 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
{%- set url_root = pathto('', 1) %}
33
{%- if url_root == '#' %}{% set url_root = '' %}{% endif %}
44
{%- if not embedded and docstitle %}
5-
{%- set titlesuffix = " — "|safe + docstitle|e %}
5+
{%- set titlesuffix = " — "|safe + docstitle|e %}
66
{%- else %}
7-
{%- set titlesuffix = "" %}
7+
{%- set titlesuffix = "" %}
88
{%- endif %}
99
{%- set lang_attr = 'en' if language == None else (language | replace('_', '-')) %}
1010
{%- set sphinx_writer = 'writer-html5' if html5_doctype else 'writer-html4' -%}
@@ -14,7 +14,8 @@
1414
{%- set sphinx_version_info = (_ver_major, _ver_minor, _ver_bugfix) -%}
1515

1616
<!DOCTYPE html>
17-
<html class="{{ sphinx_writer }}" lang="{{ lang_attr }}" >
17+
<html class="{{ sphinx_writer }}" lang="{{ lang_attr }}">
18+
1819
<head>
1920
<meta charset="utf-8" />
2021
{{- metatags }}
@@ -24,40 +25,41 @@
2425
{%- endblock -%}
2526

2627
{#- 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" />
28+
{%- if sphinx_version_info
29+
< (4, 0) -%} <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
30+
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
3031
{%- endif %}
3132
{%- 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 %} />
34-
{%- else %}
35-
<link rel="stylesheet" href="{{ pathto(css, 1) }}" type="text/css" />
36-
{%- endif %}
33+
{%- if css|attr("rel") %}
34+
<link rel="{{ css.rel }}" href="{{ pathto(css.filename, 1) }}" type="text/css" {% if css.title is not none %}
35+
title="{{ css.title }}" {% endif %} />
36+
{%- else %}
37+
<link rel="stylesheet" href="{{ pathto(css, 1) }}" type="text/css" />
38+
{%- endif %}
3739
{%- endfor %}
3840
<link rel="stylesheet" href="{{ pathto('_static/css/theme.css', 1)|e }}" type="text/css" />
3941

4042
{%- for cssfile in extra_css_files %}
41-
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
43+
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
4244
{%- endfor -%}
4345

4446
{#- FAVICON #}
4547
{%- if favicon %}
46-
{%- if sphinx_version_info < (4, 0) -%}
47-
<link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
48-
{%- else %}
49-
<link rel="shortcut icon" href="{{ favicon_url }}"/>
50-
{%- endif %}
48+
{%- if sphinx_version_info
49+
< (4, 0) -%} <link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}" />
50+
{%- else %}
51+
<link rel="shortcut icon" href="{{ favicon_url }}" />
52+
{%- endif %}
5153
{%- endif -%}
5254

5355
{#- CANONICAL URL (deprecated) #}
5456
{%- if theme_canonical_url and not pageurl %}
55-
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html"/>
57+
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html" />
5658
{%- endif -%}
5759

5860
{#- CANONICAL URL #}
5961
{%- if pageurl %}
60-
<link rel="canonical" href="{{ pageurl|e }}" />
62+
<link rel="canonical" href="{{ pageurl|e }}" />
6163
{%- endif -%}
6264

6365
{#- JAVASCRIPTS #}
@@ -66,42 +68,48 @@
6668
<script src="{{ pathto('_static/js/html5shiv.min.js', 1) }}"></script>
6769
<![endif]-->
6870
{%- if not embedded %}
69-
{# 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 #}
70-
{%- if sphinx_version_info >= (1, 8) -%}
71-
{%- if sphinx_version_info < (4, 0) -%}
72-
<script id="documentation_options" data-url_root="{{ url_root }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
73-
{%- endif -%}
74-
{%- for scriptfile in script_files %}
75-
{{ js_tag(scriptfile) }}
76-
{%- endfor %}
71+
{# XXX Sphinx 1.8.0 made this an external js-file, quick fix until we refactor the template to inherert more blocks
72+
directly from sphinx #}
73+
{%- if sphinx_version_info >= (1, 8) -%}
74+
{%- if sphinx_version_info < (4, 0) -%} <script id="documentation_options" data-url_root="{{ url_root }}"
75+
src="{{ pathto('_static/documentation_options.js', 1) }}">
76+
</script>
77+
{%- endif -%}
78+
{%- for scriptfile in script_files %}
79+
{{ js_tag(scriptfile) }}
80+
{%- endfor %}
7781
{%- else %}
78-
<script>
79-
var DOCUMENTATION_OPTIONS = {
80-
URL_ROOT:'{{ url_root }}',
81-
VERSION:'{{ release|e }}',
82-
LANGUAGE:'{{ language }}',
83-
COLLAPSE_INDEX:false,
84-
FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}',
85-
HAS_SOURCE: {{ has_source|lower }},
86-
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}'
82+
<script>
83+
var DOCUMENTATION_OPTIONS = {
84+
URL_ROOT: '{{ url_root }}',
85+
VERSION: '{{ release|e }}',
86+
LANGUAGE: '{{ language }}',
87+
COLLAPSE_INDEX: false,
88+
FILE_SUFFIX: '{{ '' if no_search_suffix else file_suffix }}',
89+
HAS_SOURCE: {{ has_source| lower }},
90+
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}'
8791
};
88-
</script>
89-
{%- for scriptfile in script_files %}
90-
<script src="{{ pathto(scriptfile, 1) }}"></script>
91-
{%- endfor %}
92+
</script>
93+
{%- for scriptfile in script_files %}
94+
<script src="{{ pathto(scriptfile, 1) }}"></script>
95+
{%- endfor %}
9296
{%- endif %}
9397
<script src="{{ pathto('_static/js/theme.js', 1) }}"></script>
98+
<script src="https://cdn.jsdelivr.net/npm/darkreader@4.9.39/darkreader.min.js"></script>
99+
<script>
100+
DarkReader.auto();
101+
</script>
94102

95103
{#- OPENSEARCH #}
96104
{%- if use_opensearch %}
97105
<link rel="search" type="application/opensearchdescription+xml"
98-
title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}"
99-
href="{{ pathto('_static/opensearch.xml', 1) }}"/>
106+
title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}"
107+
href="{{ pathto('_static/opensearch.xml', 1) }}" />
100108
{%- endif %}
101-
{%- endif %}
102-
{%- endblock %}
109+
{%- endif %}
110+
{%- endblock %}
103111

104-
{%- block linktags %}
112+
{%- block linktags %}
105113
{%- if hasdoc('about') %}
106114
<link rel="author" title="{{ _('About these documents') }}" href="{{ pathto('about') }}" />
107115
{%- endif %}
@@ -120,8 +128,8 @@
120128
{%- if prev %}
121129
<link rel="prev" title="{{ prev.title|striptags|e }}" href="{{ prev.link|e }}" />
122130
{%- endif %}
123-
{%- endblock %}
124-
{%- block extrahead %} {% endblock %}
131+
{%- endblock %}
132+
{%- block extrahead %} {% endblock %}
125133
</head>
126134

127135
<body class="wy-body-for-nav">
@@ -131,58 +139,60 @@
131139
{#- SIDE NAV, TOGGLES ON MOBILE #}
132140
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
133141
<div class="wy-side-scroll">
134-
<div class="wy-side-nav-search" {% if theme_style_nav_header_background %} style="background: {{theme_style_nav_header_background}}" {% endif %}>
142+
<div class="wy-side-nav-search" {% if theme_style_nav_header_background %}
143+
style="background: {{theme_style_nav_header_background}}" {% endif %}>
135144
{%- block sidebartitle %}
136145

137146
{%- if logo and theme_logo_only %}
138-
<a href="{{ pathto(master_doc) }}">
139-
{%- else %}
147+
<a href="{{ pathto(master_doc) }}">
148+
{%- else %}
140149
<a href="{{ pathto(master_doc) }}" class="icon icon-home"> {{ project }}
141-
{%- endif %}
150+
{%- endif %}
142151

143-
{%- if logo %}
144-
{#- Not strictly valid HTML, but it's the only way to display/scale
145-
it properly, without weird scripting or heaps of work
146-
#}
147-
{%- if sphinx_version_info < (4, 0) -%}
148-
<img src="{{ pathto('_static/' + logo, 1) }}" class="logo" alt="{{ _('Logo') }}"/>
149-
{%- else %}
150-
<img src="{{ logo_url }}" class="logo" alt="{{ _('Logo') }}"/>
151-
{%- endif %}
152-
{%- endif %}
153-
</a>
152+
{%- if logo %}
153+
{#- Not strictly valid HTML, but it's the only way to display/scale
154+
it properly, without weird scripting or heaps of work
155+
#}
156+
{%- if sphinx_version_info
157+
< (4, 0) -%} <img src="{{ pathto('_static/' + logo, 1) }}" class="logo" alt="{{ _('Logo') }}" />
158+
{%- else %}
159+
<img src="{{ logo_url }}" class="logo" alt="{{ _('Logo') }}" />
160+
{%- endif %}
161+
{%- endif %}
162+
</a>
154163

155-
{%- if theme_display_version %}
164+
{%- if theme_display_version %}
156165
{%- set nav_version = version %}
157166
{%- if READTHEDOCS and current_version %}
158-
{%- set nav_version = current_version %}
167+
{%- set nav_version = current_version %}
159168
{%- endif %}
160169
{%- if nav_version %}
161-
<div class="version">
162-
{{ nav_version }}
163-
</div>
170+
<div class="version">
171+
{{ nav_version }}
172+
</div>
173+
{%- endif %}
164174
{%- endif %}
165-
{%- endif %}
166175

167-
{%- include "searchbox.html" %}
176+
{%- include "searchbox.html" %}
168177

169-
{%- endblock %}
178+
{%- endblock %}
170179
</div>
171180

172181
{%- block navigation %}
173182
{#- Translators: This is an ARIA section label for the main navigation menu -#}
174-
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="{{ _('Navigation menu') }}">
183+
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation"
184+
aria-label="{{ _('Navigation menu') }}">
175185
{%- block menu %}
176-
{%- set toctree = toctree(maxdepth=4|int,
177-
collapse=theme_collapse_navigation|tobool,
178-
includehidden=theme_includehidden|tobool,
179-
titles_only=theme_titles_only|tobool) %}
180-
{%- if toctree %}
181-
{{ toctree }}
182-
{%- else %}
183-
<!-- Local TOC -->
184-
<div class="local-toc">{{ toc }}</div>
185-
{%- endif %}
186+
{%- set toctree = toctree(maxdepth=4|int,
187+
collapse=theme_collapse_navigation|tobool,
188+
includehidden=theme_includehidden|tobool,
189+
titles_only=theme_titles_only|tobool) %}
190+
{%- if toctree %}
191+
{{ toctree }}
192+
{%- else %}
193+
<!-- Local TOC -->
194+
<div class="local-toc">{{ toc }}</div>
195+
{%- endif %}
186196
{%- endblock %}
187197
</div>
188198
{%- endblock %}
@@ -192,67 +202,70 @@
192202
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
193203

194204
{#- MOBILE NAV, TRIGGLES SIDE NAV ON TOGGLE #}
195-
{#- Translators: This is an ARIA section label for the navigation menu that is visible when viewing the page on mobile devices -#}
196-
<nav class="wy-nav-top" aria-label="{{ _('Mobile navigation menu') }}" {% if theme_style_nav_header_background %} style="background: {{theme_style_nav_header_background}}" {% endif %}>
205+
{#- Translators: This is an ARIA section label for the navigation menu that is visible when viewing the page on
206+
mobile devices -#}
207+
<nav class="wy-nav-top" aria-label="{{ _('Mobile navigation menu') }}" {% if theme_style_nav_header_background %}
208+
style="background: {{theme_style_nav_header_background}}" {% endif %}>
197209
{%- block mobile_nav %}
198-
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
199-
<a href="{{ pathto(master_doc) }}">{{ project }}</a>
210+
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
211+
<a href="{{ pathto(master_doc) }}">{{ project }}</a>
200212
{%- endblock %}
201213
</nav>
202214

203215
<div class="wy-nav-content">
204-
{%- block content %}
216+
{%- block content %}
205217
{%- if theme_style_external_links|tobool %}
206218
<div class="rst-content style-external-links">
207-
{%- else %}
208-
<div class="rst-content">
209-
{%- endif %}
210-
{% include "breadcrumbs.html" %}
211-
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
212-
{%- block document %}
213-
<div itemprop="articleBody">
214-
{% block body %}{% endblock %}
215-
</div>
216-
{%- if self.comments()|trim %}
217-
<div class="articleComments">
218-
{%- block comments %}{% endblock %}
219-
</div>
220-
{%- endif%}
219+
{%- else %}
220+
<div class="rst-content">
221+
{%- endif %}
222+
{% include "breadcrumbs.html" %}
223+
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
224+
{%- block document %}
225+
<div itemprop="articleBody">
226+
{% block body %}{% endblock %}
227+
</div>
228+
{%- if self.comments()|trim %}
229+
<div class="articleComments">
230+
{%- block comments %}{% endblock %}
231+
</div>
232+
{%- endif%}
233+
</div>
234+
{%- endblock %}
235+
{% include "footer.html" %}
221236
</div>
222237
{%- endblock %}
223-
{% include "footer.html" %}
224238
</div>
225-
{%- endblock %}
226-
</div>
227239
</section>
228240
</div>
229241
{% include "versions.html" -%}
230242

231243
<script>
232-
jQuery(function () {
233-
SphinxRtdTheme.Navigation.enable({{ 'true' if theme_sticky_navigation|tobool else 'false' }});
244+
jQuery(function () {
245+
SphinxRtdTheme.Navigation.enable({{ 'true' if theme_sticky_navigation | tobool else 'false' }});
234246
});
235247
</script>
236248

237249
{#- Do not conflict with RTD insertion of analytics script #}
238250
{%- if not READTHEDOCS %}
239-
{%- if theme_analytics_id %}
240-
<!-- Theme Analytics -->
241-
<script async src="https://www.googletagmanager.com/gtag/js?id={{ theme_analytics_id }}"></script>
242-
<script>
243-
window.dataLayer = window.dataLayer || [];
244-
function gtag(){dataLayer.push(arguments);}
245-
gtag('js', new Date());
251+
{%- if theme_analytics_id %}
252+
<!-- Theme Analytics -->
253+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ theme_analytics_id }}"></script>
254+
<script>
255+
window.dataLayer = window.dataLayer || [];
256+
function gtag() { dataLayer.push(arguments); }
257+
gtag('js', new Date());
246258

247-
gtag('config', '{{ theme_analytics_id }}', {
248-
'anonymize_ip': {{ 'true' if theme_analytics_anonymize_ip|tobool else 'false' }},
259+
gtag('config', '{{ theme_analytics_id }}', {
260+
'anonymize_ip': {{ 'true' if theme_analytics_anonymize_ip | tobool else 'false' }},
249261
});
250-
</script>
262+
</script>
251263

252-
{%- endif %}
264+
{%- endif %}
253265
{%- endif %}
254266

255267
{%- block footer %} {% endblock %}
256268

257269
</body>
258-
</html>
270+
271+
</html>

0 commit comments

Comments
 (0)