From: Thanh Ha Date: Mon, 11 Jun 2018 02:46:03 +0000 (-0400) Subject: Set docs version from git X-Git-Tag: v0.21.0~4^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F58%2F11158%2F5;p=releng%2Fglobal-jjb.git Set docs version from git Removes the need to modify conf.py every time we release. Change-Id: I010c5a4eaf2f2c88156db561218919aa470eaea0 Signed-off-by: Thanh Ha --- diff --git a/docs/conf.py b/docs/conf.py index d5decd53..b007a9e9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,10 +18,24 @@ # 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. @@ -67,7 +81,13 @@ author = 'Linux Foundation Releng' # built documents. # # The short X.Y version. -version = '0.21.0-dev' +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