Skip to content

Commit

Permalink
Automatic version parser for sphinx
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Apr 8, 2021
1 parent b13fc41 commit 0cf2e6b
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,31 @@
copyright = '2020, Tilen MAJERLE'
author = 'Tilen MAJERLE'

# The full version, including alpha/beta/rc tags
version = 'v2.1.0'

# Try to get branch at which this is running
# 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 = ''

# Get current branch
res = os.popen('git branch').read().strip()
for line in res.split("\n"):
if line[0] == '*':
git_branch = line[1:].strip()

# Decision for display version
try:
if git_branch.index('develop') >= 0:
version = "latest-develop"
except Exception:
print("Exception for index check")

# For debugging purpose
if git_branch == 'master' or git_branch == 'main':
version = os.popen('git describe --tags --abbrev=0').read().strip()
if version == '':
version = 'v0.0.0'
elif git_branch == 'develop':
version = 'latest-develop'
else:
version = 'branch-' + git_branch

# For debugging purpose only
print("GIT BRANCH: " + git_branch)
print("VERSION: " + version)
print("GIT VERSION: " + version)

# -- General configuration ---------------------------------------------------

Expand Down

0 comments on commit 0cf2e6b

Please sign in to comment.