guide: When running in Read The Docs, get version from its environment

Git isn't available in the Read The Docs build, but we don't actually need
it there anyway because we are told the version number that Read The Docs
thinks it is building.
This commit is contained in:
Martin Atkins 2018-08-25 17:01:35 -07:00
parent c6f6feed76
commit 33120477c7
1 changed files with 7 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import subprocess
import os
import os.path
# -- Project information -----------------------------------------------------
@ -7,12 +8,15 @@ project = u'HCL'
copyright = u'2018, HashiCorp'
author = u'HashiCorp'
git_version = subprocess.check_output(['git', 'describe', '--always']).strip()
if 'READTHEDOCS_VERSION' in os.environ:
version_str = os.environ['READTHEDOCS_VERSION']
else:
version_str = subprocess.check_output(['git', 'describe', '--always']).strip()
# The short X.Y version
version = unicode(git_version)
version = unicode(version_str)
# The full version, including alpha/beta/rc tags
release = unicode(git_version)
release = unicode(version_str)
# -- General configuration ---------------------------------------------------