diff options
author | Jani Nikula <jani.nikula@intel.com> | 2016-05-28 15:25:41 +0300 |
---|---|---|
committer | Jani Nikula <jani.nikula@intel.com> | 2016-05-30 13:38:53 +0300 |
commit | c13ce448c8532965eb4e1115e78cb5b8ff8261a3 (patch) | |
tree | 9045c881acf6badba6f0d32572cd0f845d33c8e9 /Documentation/conf.py | |
parent | 24dcdeb28b55afafa9cdf6acedd78cf1aa8f8428 (diff) | |
download | op-kernel-dev-c13ce448c8532965eb4e1115e78cb5b8ff8261a3.zip op-kernel-dev-c13ce448c8532965eb4e1115e78cb5b8ff8261a3.tar.gz |
Documentation/sphinx: set version and release properly
Read the version and release from the top level Makefile (for use when
Sphinx is invoked directly, by e.g. Read the Docs), but override them
via Sphinx command line arguments in a normal documentation build.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'Documentation/conf.py')
-rw-r--r-- | Documentation/conf.py | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/Documentation/conf.py b/Documentation/conf.py index 8b72577..6cc41a0 100644 --- a/Documentation/conf.py +++ b/Documentation/conf.py @@ -60,10 +60,31 @@ author = 'The kernel development community' # |version| and |release|, also used in various other places throughout the # built documents. # -# The short X.Y version. -version = '4.5' -# The full version, including alpha/beta/rc tags. -release = '4.5' +# In a normal build, version and release are are set to KERNELVERSION and +# KERNELRELEASE, respectively, from the Makefile via Sphinx command line +# arguments. +# +# 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 = None + makefile_patchlevel = None + for line in open('../Makefile'): + key, val = [x.strip() for x in line.split('=', 2)] + if key == 'VERSION': + makefile_version = val + elif key == 'PATCHLEVEL': + makefile_patchlevel = val + if makefile_version and makefile_patchlevel: + break +except: + pass +finally: + if makefile_version and makefile_patchlevel: + version = release = makefile_version + '.' + makefile_patchlevel + else: + sys.stderr.write('Warning: Could not extract kernel version\n') + version = release = "unknown version" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. |