From f51c942f8edd76cb1dfa107ed98c1d77ba9f28eb Mon Sep 17 00:00:00 2001 From: kakwa Date: Mon, 12 Sep 2016 19:33:31 +0200 Subject: [PATCH] recover version directory from CMakeLists.txt this avoid mistakes caused by double declaration of the version in CMakeLists.txt and conf.py --- docs/conf.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index e2cf2f7..ef94c55 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,9 +16,18 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. import os import sys +import re sys.path.insert(0, os.path.abspath('..')) +def get_version(): + cmake = os.path.join(os.path.dirname(__file__),'../CMakeLists.txt') + with open(cmake) as f: + for line in f.readlines(): + m = re.search('set\(VERSION ([\.0-9]+)\)', line) + if m: + return m.group(1) + # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. @@ -50,7 +59,7 @@ copyright = u'2016, Pierre-Francois Carpentier' # # The short X.Y version. # The full version, including alpha/beta/rc tags. -release = '0.0.2' +release = get_version() # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages.