@@ -343,11 +343,28 @@ def setup(app):
343
343
app .connect ('html-page-context' , analytics )
344
344
app .add_config_value ('google_analytics_key' , '' , 'env' )
345
345
346
+ app .connect ('html-page-context' , versionize )
347
+ app .add_config_value ('versions' , '' , 'env' )
348
+
346
349
app .connect ('html-page-context' , localize )
347
350
app .add_config_value ('languages' , '' , 'env' )
348
351
349
352
app .connect ('doctree-resolved' , tag_toctrees )
350
353
354
+ def versionize (app , pagename , templatename , context , doctree ):
355
+ """ Adds a version switcher below the menu, requires ``canonical_root``
356
+ and ``versions`` (an ordered, space-separated lists of all possible
357
+ versions).
358
+ """
359
+ if not (app .config .canonical_root and app .config .versions ):
360
+ return
361
+
362
+ context ['versions' ] = [
363
+ (vs , _build_url (app .config .canonical_root , vs , pagename ))
364
+ for vs in app .config .versions .split (',' )
365
+ if vs != app .config .version
366
+ ]
367
+
351
368
def analytics (app , pagename , templatename , context , doctree ):
352
369
if not app .config .google_analytics_key :
353
370
return
0 commit comments