8000 [ADD] conf: display version number in the switcher app · hamoodeh8889/documentation-user@cd41235 · GitHub
[go: up one dir, main page]

Skip to content

Commit cd41235

Browse files
committed
[ADD] conf: display version number in the switcher app
1 parent be7b75f commit cd41235

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

conf.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,28 @@ def setup(app):
333333
app.connect('html-page-context', analytics)
334334
app.add_config_value('google_analytics_key', '', 'env')
335335

336+
app.connect('html-page-context', versionize)
337+
app.add_config_value('versions', '', 'env')
338+
336339
app.connect('html-page-context', localize)
337340
app.add_config_value('languages', '', 'env')
338341

339342
app.connect('doctree-resolved', tag_toctrees)
340343

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+
341358
def analytics(app, pagename, templatename, context, doctree):
342359
if not app.config.google_analytics_key:
343360
return

0 commit comments

Comments
 (0)
0