Get version string for docs from CMakeLists.txt

Because it's better to have a single source.
Someone else will need to integrate the makefiles though.
develop
PeridexisErrant 2015-09-24 13:33:56 +10:00
parent ce09c8e099
commit 79263847a6
1 changed files with 16 additions and 4 deletions

@ -13,6 +13,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import fnmatch
import sys
import os
import shlex
@ -54,11 +55,22 @@ author = 'The DFHack Team'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
def get_version():
"""Return the DFHack version string, from CMakeLists.txt"""
version, release = '', ''
with open('CMakeLists.txt') as f:
for s in f.readlines():
if fnmatch.fnmatch(s.upper(), 'SET(DF_VERSION "?.??.??")\n'):
version = s.upper().replace('SET(DF_VERSION "', '')
elif fnmatch.fnmatch(s.upper(), 'SET(DFHACK_RELEASE "r*")\n'):
release = s.upper().replace('SET(DFHACK_RELEASE "', '').lower()
return (version + '-' + release).replace('")\n', '')
# The short X.Y version.
version = '0.40.24-r3'
version = get_version()
# The full version, including alpha/beta/rc tags.
release = '0.40.24-r3'
release = get_version()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -75,7 +87,7 @@ language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['docs/_build']
exclude_patterns = ['docs/_build/*', 'depends/*']
# The reST default role (used for this markup: `text`) to use for all
# documents.