From 3393ad623fde05ce8957d556ae5430b436c6100a Mon Sep 17 00:00:00 2001 From: bret curtis Date: Tue, 27 Feb 2018 16:15:43 +0100 Subject: [PATCH] fix rtd --- docs/source/conf.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index b18b40c50..e3fe58bc7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -60,13 +60,29 @@ copyright = u'2017, OpenMW Team' # The short X.Y version. # The full version, including alpha/beta/rc tags. +def get_openmw_version(haystack): + needle = 'OPENMW_VERSION_MAJOR' + line_counter = 0 + for hay in haystack: + if needle in str(hay): + break + line_counter += 1 + + if line_counter == 0: + raise ImportError('Unable to find OpenMW Version') + + version = '.'.join([haystack[line_counter][1][1].contents, + haystack[line_counter+1][1][1].contents, + haystack[line_counter+2][1][1].contents]) + return version + + try: from parse_cmake import parsing cmake_raw = open(project_root+'/CMakeLists.txt', 'r').read() cmake_data = parsing.parse(cmake_raw) - release = version = '.'.join([cmake_data[24][1][1].contents, - cmake_data[25][1][1].contents, - cmake_data[26][1][1].contents]) + release = version = get_openmw_version(cmake_data) + except ImportError: release = "UNRELEASED" print("WARNING: Unable to import parse_cmake, version will be set to: {0}.".format(release))