Fix: Update Sphinx to fix RTD build
[releng/global-jjb.git] / docs / conf.py
index 346af70..e9f9271 100644 (file)
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 #
 import os
+import subprocess
 import sys
 import sphinx_bootstrap_theme
+
 sys.path.insert(0, os.path.abspath('..'))
 
+
+def format_version(version):
+    fmt = '{tag}.dev{commitcount}+{gitsha}'
+    parts = version.split('-')
+    assert len(parts) in (3, 4)
+    dirty = len(parts) == 4
+    tag, count, sha = parts[:3]
+    if count == '0' and not dirty:
+        return tag
+    return fmt.format(tag=tag, commitcount=count, gitsha=sha.lstrip('g'))
+
+
 # -- General configuration ------------------------------------------------
 
 # If your documentation needs a minimal Sphinx version, state it here.
@@ -32,6 +46,7 @@ sys.path.insert(0, os.path.abspath('..'))
 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
 # ones.
 extensions = [
+    'reno.sphinxext',
     'sphinx.ext.autodoc',
     'sphinx.ext.doctest',
     'sphinx.ext.intersphinx',
@@ -59,7 +74,7 @@ master_doc = 'index'
 
 # General information about the project.
 project = 'lf-releng-global-jjb'
-copyright = '2017, The Linux Foundation'
+copyright = '2019, The Linux Foundation'
 author = 'Linux Foundation Releng'
 
 # The version info for the project you're documenting, acts as replacement for
@@ -67,7 +82,13 @@ author = 'Linux Foundation Releng'
 # built documents.
 #
 # The short X.Y version.
-version = '0.19.2'
+command = 'git describe --tags --long --dirty'
+try:
+    git_version = format_version(
+        subprocess.check_output(command.split()).decode('utf-8').strip())
+except subprocess.CalledProcessError:  # Handle docs builds from tarball
+    git_version = "v0.0.9999-local"
+version = git_version
 # The full version, including alpha/beta/rc tags.
 release = version
 
@@ -76,7 +97,7 @@ release = version
 #
 # This is also used if you do content translation via gettext catalogs.
 # Usually you set "language" from the command line for these cases.
-language = None
+language = "en"
 
 # There are two options for replacing |today|: either, you set today to some
 # non-false value, then it is used:
@@ -255,7 +276,8 @@ htmlhelp_basename = 'LinuxFoundationReleaseEngineeringGJJBdoc'
 
 # Example configuration for intersphinx: refer to the Python standard library.
 intersphinx_mapping = {
-    'jjb': ('https://docs.openstack.org/infra/jenkins-job-builder/', None),
+    'jjb': ('https://jenkins-job-builder.readthedocs.io/en/latest/', None),
+    'lfdocs': ('http://docs.releng.linuxfoundation.org/en/latest/', None),
     'lftools': ('http://lftools.releng.linuxfoundation.org/en/latest/', None),
     'python': ('https://docs.python.org/', None),
 }