Automate docs version from our setup.cfg
Our docs version is out of date (2.7), so this moves towards automating
this version. The version is displayed in intersphinx links and in the
title of the page. I didn't use the `readthedocs.__init__` method to
avoid an import into our docs.
@@ -4,6 +4,7 @@ from __future__ import division, print_function, unicode_literals
import os
import sys
+from configparser import RawConfigParser
import sphinx_rtd_theme
@@ -18,6 +19,13 @@ import django
django.setup()
+def get_version():
+ """Return package version from setup.cfg."""
+ config = RawConfigParser()
+ config.read('../setup.cfg')
+ return config.get('metadata', 'version')
+
+
sys.path.append(os.path.abspath('_ext'))
extensions = [
'sphinx.ext.autosectionlabel',
@@ -40,7 +48,7 @@ project = u'Read the Docs'
copyright = '2010-{}, Read the Docs, Inc & contributors'.format(
timezone.now().year
)
-version = '2.7'
+version = get_version()
release = version
exclude_patterns = ['_build']
default_role = 'obj'
