From aec08861c8c24b546be9d95bde3fe3d50926bac0 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sat, 10 Dec 2016 21:40:10 +0100 Subject: get documentation version from latest Git tag. --- doc/conf.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'doc/conf.py') diff --git a/doc/conf.py b/doc/conf.py index e9c53f9ad..650942af1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -54,10 +54,23 @@ author = u'Tristan Gingold' # |version| and |release|, also used in various other places throughout the # built documents. # -# The short X.Y version. -version = '0.33' -# The full version, including alpha/beta/rc tags. -release = '0.33' +def _IsUnderGitControl(): + return (check_output(["git", "rev-parse", "--is-inside-work-tree"], universal_newlines=True).strip() == "true") + +def _LatestTagName(): + return check_output(["git", "describe", "--abbrev=0", "--tags"], universal_newlines=True).strip() + +version = "0.33" # The short X.Y version. +release = "0.33" # The full version, including alpha/beta/rc tags. +try: + if _IsUnderGitControl: + latestTagName = _LatestTagName()[1:] # remove prefix "v" + versionParts = latestTagName.split("-")[0].split(".") + + version = ".".join(versionParts[:2]) + release = version # ".".join(versionParts[:3]) +except: + pass # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -- cgit v1.2.3