[doc] automatically detect version

We prefer the VERSION file if available, otherwise falling back to
querying version directly from git.
This commit is contained in:
Quantum 2021-12-25 19:45:28 -05:00 committed by Geoffrey McRae
parent 6f8745a89b
commit 4dccd725bf

View File

@ -5,6 +5,7 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
from pathlib import Path
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@ -22,7 +23,19 @@ copyright = '2021, Looking Glass team'
author = 'Geoffrey McRae and the Looking Glass team'
# The full version, including alpha/beta/rc tags
release = 'B4'
try:
with open(Path(__file__).parent.parent / 'VERSION') as f:
release = f.read().strip()
except IOError:
import subprocess
try:
release = subprocess.check_output([
'gist', 'describe', '--always', '--abbrev=10', '--dirty=+', '--tags'
]).decode('utf-8').strip()
except (subprocess.CalledProcessError, OSError):
release = '(unknown version)'
del subprocess
rst_prolog = """
.. |license| replace:: GPLv2