doc: read version from Makefile

Change-Id: I6edb5ee53cdff1c687e97663c93ddaa3b09a9288
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2016-12-23 12:25:06 -05:00 committed by Anas Nashif
parent ae6f8785cd
commit 762bd85807
2 changed files with 27 additions and 9 deletions

View file

@ -52,14 +52,32 @@ project = u'Zephyr Project'
copyright = u'2015, Intel Corporation, Wind River Systems, Inc'
author = u'many'
# 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.
#
# The short X.Y version.
version = os.getenv('KERNELVERSION','0.1.0')
# The full version, including alpha/beta/rc tags.
release = os.getenv('KERNELVERSION','0.1.0')
# The following code tries to extract the information by reading the Makefile,
# when Sphinx is run directly (e.g. by Read the Docs).
try:
makefile_version_major = None
makefile_version_minor = None
makefile_patchlevel = None
for line in open('../Makefile'):
key, val = [x.strip() for x in line.split('=', 2)]
if key == 'VERSION_MAJOR':
makefile_version_major = val
if key == 'VERSION_MINOR':
makefile_version_minor = val
elif key == 'PATCHLEVEL':
makefile_patchlevel = val
if makefile_version_major and makefile_version_minor and makefile_patchlevel:
break
except:
pass
finally:
if makefile_version_major and makefile_version_minor and makefile_patchlevel:
version = release = makefile_version_major + '.' + makefile_version_minor + '.' + makefile_patchlevel
else:
sys.stderr.write('Warning: Could not extract kernel version\n')
version = release = "unknown version"
version = release = os.getenv('KERNELVERSION','0.1.0')
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View file

@ -14,7 +14,7 @@ Zephyr Project Documentation
.. only:: development
Welcome to the Zephyr Project's documentation. This is the documentation of the
master tree under development.
master tree under development (version |version|).
Documentation for released versions of Zephyr can be found at
``https://www.zephyrproject.org/doc/<version>``. The following documentation