diff --git a/doc/source/usage.rst b/doc/source/usage.rst index 5aca6b5..89d9a06 100644 --- a/doc/source/usage.rst +++ b/doc/source/usage.rst @@ -24,3 +24,14 @@ of projects, but to ensure that it is correct in all situations it is best to set the value in conf.py:: oslosphinx_cgit_link = 'http://git.openstack.org/cgit/openstack/oslosphinx' + +Showing Older Versions of Documentation +======================================= + +``oslosphinx`` can automatically add links for previous versions of your +project's documentation to the sidebar. If this feature is enabled links +will be generated for each git tag. To enable this behavior, set:: + + html_theme_options = {'show_other_versions': True} + +in your conf.py. diff --git a/oslosphinx/__init__.py b/oslosphinx/__init__.py index 9a97c36..94738e8 100644 --- a/oslosphinx/__init__.py +++ b/oslosphinx/__init__.py @@ -43,6 +43,13 @@ def _guess_cgit_link(): def _html_page_context(app, pagename, templatename, context, doctree): # Insert the cgit link into the template context. context['cgit_link'] = app.config.oslosphinx_cgit_link + context['other_versions'] = _get_other_versions(app) + return None + + +def _get_other_versions(app): + if not app.config.html_theme_options.get('show_other_versions', False): + return [] git_cmd = ["git", "tag"] try: @@ -62,8 +69,7 @@ def _html_page_context(app, pagename, templatename, context, doctree): # Don't show alpha, beta or release candidate tags and 'rc' not in t and 'a' not in t and 'b' not in t ][:-5:-1] - context['other_versions'] = other_versions - return None + return other_versions def builder_inited(app): diff --git a/oslosphinx/theme/openstack/theme.conf b/oslosphinx/theme/openstack/theme.conf index e2b8bfe..2d5cc29 100644 --- a/oslosphinx/theme/openstack/theme.conf +++ b/oslosphinx/theme/openstack/theme.conf @@ -5,3 +5,4 @@ pygments_style = tango [options] incubating = false +show_other_versions = false