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