Skip to content

Commit 0f1a106

Browse files
committed
Use default quote char, same as Black
1 parent 3692ce8 commit 0f1a106

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

.pre-commit-config.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ repos:
4848
hooks:
4949
- id: prettier
5050
files: templates/switchers.js
51-
args: [--single-quote]
5251

5352
- repo: meta
5453
hooks:

templates/switchers.js

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
'use strict';
1+
"use strict";
22

33
// File URIs must begin with either one or three forward slashes
4-
const _is_file_uri = (uri) => uri.startsWith('file:/');
4+
const _is_file_uri = (uri) => uri.startsWith("file:/");
55

66
const _IS_LOCAL = _is_file_uri(window.location.href);
7-
const _CURRENT_RELEASE = DOCUMENTATION_OPTIONS.VERSION || '';
8-
const _CURRENT_VERSION = _CURRENT_RELEASE.split('.', 2).join('.');
9-
const _CURRENT_LANGUAGE = DOCUMENTATION_OPTIONS.LANGUAGE?.toLowerCase() || 'en';
7+
const _CURRENT_RELEASE = DOCUMENTATION_OPTIONS.VERSION || "";
8+
const _CURRENT_VERSION = _CURRENT_RELEASE.split(".", 2).join(".");
9+
const _CURRENT_LANGUAGE = DOCUMENTATION_OPTIONS.LANGUAGE?.toLowerCase() || "en";
1010
const _CURRENT_PREFIX = (() => {
1111
if (_IS_LOCAL) return null;
1212
// Sphinx 7.2+ defines the content root data attribute in the HTML element.
@@ -15,8 +15,8 @@ const _CURRENT_PREFIX = (() => {
1515
return new URL(_CONTENT_ROOT, window.location).pathname;
1616
}
1717
// Fallback for older versions of Sphinx (used in Python 3.10 and older).
18-
const _NUM_PREFIX_PARTS = _CURRENT_LANGUAGE === 'en' ? 2 : 3;
19-
return window.location.pathname.split('/', _NUM_PREFIX_PARTS).join('/') + '/';
18+
const _NUM_PREFIX_PARTS = _CURRENT_LANGUAGE === "en" ? 2 : 3;
19+
return window.location.pathname.split("/", _NUM_PREFIX_PARTS).join("/") + "/";
2020
})();
2121

2222
const _ALL_VERSIONS = new Map($VERSIONS);
@@ -28,15 +28,15 @@ const _ALL_LANGUAGES = new Map($LANGUAGES);
2828
* @private
2929
*/
3030
const _create_version_select = (versions) => {
31-
const select = document.createElement('select');
32-
select.className = 'version-select';
31+
const select = document.createElement("select");
32+
select.className = "version-select";
3333
if (_IS_LOCAL) {
3434
select.disabled = true;
35-
select.title = 'Version switching is disabled in local builds';
35+
select.title = "Version switching is disabled in local builds";
3636
}
3737

3838
for (const [version, title] of versions) {
39-
const option = document.createElement('option');
39+
const option = document.createElement("option");
4040
option.value = version;
4141
if (version === _CURRENT_VERSION) {
4242
option.text = _CURRENT_RELEASE;
@@ -61,15 +61,15 @@ const _create_language_select = (languages) => {
6161
languages.set(_CURRENT_LANGUAGE, _CURRENT_LANGUAGE);
6262
}
6363

64-
const select = document.createElement('select');
65-
select.className = 'language-select';
64+
const select = document.createElement("select");
65+
select.className = "language-select";
6666
if (_IS_LOCAL) {
6767
select.disabled = true;
68-
select.title = 'Language switching is disabled in local builds';
68+
select.title = "Language switching is disabled in local builds";
6969
}
7070

7171
for (const [language, title] of languages) {
72-
const option = document.createElement('option');
72+
const option = document.createElement("option");
7373
option.value = language;
7474
option.text = title;
7575
if (language === _CURRENT_LANGUAGE) option.selected = true;
@@ -88,7 +88,7 @@ const _navigate_to_first_existing = async (urls) => {
8888
// Navigate to the first existing URL in urls.
8989
for (const url of urls) {
9090
try {
91-
const response = await fetch(url, { method: 'HEAD' });
91+
const response = await fetch(url, { method: "HEAD" });
9292
if (response.ok) {
9393
window.location.href = url;
9494
return url;
@@ -99,8 +99,8 @@ const _navigate_to_first_existing = async (urls) => {
9999
}
100100

101101
// if all else fails, redirect to the d.p.o root
102-
window.location.href = '/';
103-
return '/';
102+
window.location.href = "/";
103+
return "/";
104104
};
105105

106106
/**
@@ -116,7 +116,7 @@ const _on_version_switch = async (event) => {
116116
// English has no language prefix.
117117
const new_prefix_en = `/${selected_version}/`;
118118
const new_prefix =
119-
_CURRENT_LANGUAGE === 'en'
119+
_CURRENT_LANGUAGE === "en"
120120
? new_prefix_en
121121
: `/${_CURRENT_LANGUAGE}/${selected_version}/`;
122122
if (_CURRENT_PREFIX !== new_prefix) {
@@ -146,7 +146,7 @@ const _on_language_switch = async (event) => {
146146
const selected_language = event.target.value;
147147
// English has no language prefix.
148148
const new_prefix =
149-
selected_language === 'en'
149+
selected_language === "en"
150150
? `/${_CURRENT_VERSION}/`
151151
: `/${selected_language}/${_CURRENT_VERSION}/`;
152152
if (_CURRENT_PREFIX !== new_prefix) {
@@ -170,24 +170,24 @@ const _initialise_switchers = () => {
170170
const languages = _ALL_LANGUAGES;
171171

172172
document
173-
.querySelectorAll('.version_switcher_placeholder')
173+
.querySelectorAll(".version_switcher_placeholder")
174174
.forEach((placeholder) => {
175175
const s = _create_version_select(versions);
176-
s.addEventListener('change', _on_version_switch);
176+
s.addEventListener("change", _on_version_switch);
177177
placeholder.append(s);
178178
});
179179

180180
document
181-
.querySelectorAll('.language_switcher_placeholder')
181+
.querySelectorAll(".language_switcher_placeholder")
182182
.forEach((placeholder) => {
183183
const s = _create_language_select(languages);
184-
s.addEventListener('change', _on_language_switch);
184+
s.addEventListener("change", _on_language_switch);
185185
placeholder.append(s);
186186
});
187187
};
188188

189-
if (document.readyState !== 'loading') {
189+
if (document.readyState !== "loading") {
190190
_initialise_switchers();
191191
} else {
192-
document.addEventListener('DOMContentLoaded', _initialise_switchers);
192+
document.addEventListener("DOMContentLoaded", _initialise_switchers);
193193
}

0 commit comments

Comments
 (0)