summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Stanek <dstanek@dstanek.com>2016-07-11 16:49:48 +0000
committerDavid Stanek <dstanek@dstanek.com>2016-07-12 16:18:39 +0000
commit3bcdfc6b77212ce802763c4fadea0bed08ca42fe (patch)
tree9d57716e28ebd32b0b4aa01141c4c976f77b124b
parentdc8baacfbd77be30b4b3434bf8ee4d587b6e772f (diff)
downloadoslosphinx-3bcdfc6b77212ce802763c4fadea0bed08ca42fe.tar.gz
Allow "Other Versions" section to be configurable4.7.0
Adds a new option that allows the "Other Versions" section to be removed if a project isn't interested in showing links to older versions. The default value is False which means that it will be hidden. Even though the setting is not backward compatible there are enough broken documentation links in the OpenStack projects that this should be opt-in behavior. Change-Id: Ic4b47b19aa9db38557c37aed7722174b7dbdf4a1 Closes-Bug: #1599260
-rw-r--r--doc/source/usage.rst11
-rw-r--r--oslosphinx/__init__.py10
-rw-r--r--oslosphinx/theme/openstack/theme.conf1
3 files changed, 20 insertions, 2 deletions
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