Automatic version parser for sphinx

This commit is contained in:
Tilen Majerle 2021-04-08 19:07:32 +02:00
parent 0ee6df331d
commit d741f5df37

View File

@ -26,27 +26,31 @@ project = 'LwSHELL'
copyright = '2020, Tilen MAJERLE' copyright = '2020, Tilen MAJERLE'
author = 'Tilen MAJERLE' author = 'Tilen MAJERLE'
# The full version, including alpha/beta/rc tags
version = '$_version_$'
# Try to get branch at which this is running # Try to get branch at which this is running
# and try to determine which version to display in sphinx # and try to determine which version to display in sphinx
# Version is using git tag if on master or "latest-develop" if on develop branch
version = ''
git_branch = '' git_branch = ''
# Get current branch
res = os.popen('git branch').read().strip() res = os.popen('git branch').read().strip()
for line in res.split("\n"): for line in res.split("\n"):
if line[0] == '*': if line[0] == '*':
git_branch = line[1:].strip() git_branch = line[1:].strip()
# Decision for display version # Decision for display version
try: if git_branch == 'master' or git_branch == 'main':
if git_branch.index('develop') >= 0: version = os.popen('git describe --tags --abbrev=0').read().strip()
version = "latest-develop" if version == '':
except Exception: version = 'v0.0.0'
print("Exception for index check") elif git_branch == 'develop':
version = 'latest-develop'
else:
version = 'branch-' + git_branch
# For debugging purpose # For debugging purpose only
print("GIT BRANCH: " + git_branch) print("GIT BRANCH: " + git_branch)
print("VERSION: " + version) print("GIT VERSION: " + version)
# -- General configuration --------------------------------------------------- # -- General configuration ---------------------------------------------------