Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
doc: fix an error if the doc is not generated from github
Browse files Browse the repository at this point in the history
The commit 57c45c0 expect Sphinx to find the environment variable
RELEASE_TAG.
It seems it's only the case when the documentation is generated from
github using the workflow defined in the release.yml file.

This commit allows to generate the doc from outside github, by setting
version to the current commit id if we are on a git repository, and
"n/a" otherwise.
  • Loading branch information
sbourdelin committed May 14, 2021
1 parent fa2a873 commit f94dc20
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion doc/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import subprocess
# import sys
# sys.path.insert(0, os.path.abspath('.'))

Expand All @@ -24,7 +25,16 @@
author = 'SiFive Inc.'

# The short X.Y version
version = os.environ['RELEASE_TAG']
# if github provides us a ref or tag
if 'RELEASE_TAG' in os.environ:
version = os.environ['RELEASE_TAG']
# if we are in a git repository
elif subprocess.call(["git", "branch"], stderr=subprocess.STDOUT, stdout=open(os.devnull, 'w')) == 0:
# set version to the current commit id
version = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip().decode('ascii')
else:
version = "n/a"

# The full version, including alpha/beta/rc tags
release = version

Expand Down

0 comments on commit f94dc20

Please sign in to comment.