Skip to content

Commit 8f6950e

Browse files
authored
Merge pull request #3246 from sommersoft/doc_title_tag
RTD: Set Version/Release For Sphinx
2 parents d8cc479 + 3a95480 commit 8f6950e

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ _build
5757
######################
5858
genrst/
5959
/autoapi/
60-
/shared-bindings/**/*.rst
60+
/shared-bindings/*/**/*.rst
6161

6262
# ctags and similar
6363
###################
@@ -80,3 +80,8 @@ TAGS
8080
*.mo
8181

8282
.vscode
83+
84+
# Python Virtual Environments
85+
####################
86+
.venv
87+
.env

conf.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import json
2121
import logging
2222
import os
23+
import re
2324
import subprocess
2425
import sys
2526
import urllib.parse
@@ -106,7 +107,25 @@
106107
#
107108
# We don't follow "The short X.Y version" vs "The full version, including alpha/beta/rc tags"
108109
# breakdown, so use the same version identifier for both to avoid confusion.
109-
version = release = '0.0.0'
110+
111+
final_version = ""
112+
git_describe = subprocess.run(
113+
["git", "describe", "--dirty", "--tags"],
114+
stdout=subprocess.PIPE,
115+
stderr=subprocess.STDOUT,
116+
encoding="utf-8"
117+
)
118+
if git_describe.returncode == 0:
119+
git_version = re.search(
120+
r"^\d(?:\.\d){0,2}(?:\-(?:alpha|beta|rc)\.\d+){0,1}",
121+
str(git_describe.stdout)
122+
)
123+
if git_version:
124+
final_version = git_version[0]
125+
else:
126+
print("Failed to retrieve git version:", git_describe.stdout)
127+
128+
version = release = final_version
110129

111130
# The language for content autogenerated by Sphinx. Refer to documentation
112131
# for a list of supported languages.

0 commit comments

Comments
 (0)