@@ -28,6 +28,30 @@ const _CURRENT_PREFIX = (() => {
28
28
const _ALL_VERSIONS = new Map ( $VERSIONS ) ;
29
29
const _ALL_LANGUAGES = new Map ( $LANGUAGES ) ;
30
30
31
+ /**
32
+ * Required for Python 3.7 and earlier.
33
+ * @returns {void }
34
+ * @private
35
+ */
36
+ const _create_placeholders_if_missing = ( ) => {
37
+ if ( document . querySelectorAll ( ".version_switcher_placeholder" ) . length ) return ;
38
+
39
+ const items = document . querySelectorAll ( "body>div.related>ul>li:not(.right)" ) ;
40
+ for ( const item of items ) {
41
+ if ( item . innerText . toLowerCase ( ) . includes ( "documentation" ) ) {
42
+ const container = document . createElement ( "li" ) ;
43
+ container . className = "switchers" ;
44
+ for ( const placeholder_name of [ "language" , "version" ] ) {
45
+ const placeholder = document . createElement ( "div" ) ;
46
+ placeholder . className = `${ placeholder_name } _switcher_placeholder` ;
47
+ container . appendChild ( placeholder ) ;
48
+ }
49
+ item . parentElement . insertBefore ( container , item ) ;
50
+ return ;
51
+ }
52
+ }
53
+ } ;
54
+
31
55
/**
32
56
* @param {Map<string, string> } versions
33
57
* @returns {HTMLSelectElement }
@@ -175,6 +199,8 @@ const _initialise_switchers = () => {
175
199
const versions = _ALL_VERSIONS ;
176
200
const languages = _ALL_LANGUAGES ;
177
201
202
+ _create_placeholders_if_missing ( ) ;
203
+
178
204
document
179
205
. querySelectorAll ( ".version_switcher_placeholder" )
180
206
. forEach ( ( placeholder ) => {
0 commit comments