|
1 | 1 | import re |
2 | 2 |
|
3 | 3 | project = "discord-ext-ipc" |
4 | | -copyright = "2021, Ext-Creators" |
| 4 | +copyright = "2020-present, Ext-Creators" |
5 | 5 | author = "Ext-Creators" |
6 | 6 |
|
| 7 | +_version_regex = r"^version = ('|\")((?:[0-9]+\.)*[0-9]+(?:\.?([a-z]+)(?:\.?[0-9])?)?)\1$" |
| 8 | + |
7 | 9 | with open("../discord/ext/ipc/__init__.py") as stream: |
8 | | - release = version = re.search( |
9 | | - r"^__version__\s*=\s*[\'\"]([^\'\"]*)[\'\"]", stream.read(), re.MULTILINE |
10 | | - ).group(1) |
| 10 | + match = re.search(_version_regex, stream.read(), re.MULTILINE) |
| 11 | + |
| 12 | +version = match.group(2) |
| 13 | + |
| 14 | +if match.group(3) is not None: |
| 15 | + try: |
| 16 | + import subprocess |
| 17 | + |
| 18 | + process = subprocess.Popen(["git", "rev-list", "--count", "HEAD"], stdout=subprocess.PIPE) |
| 19 | + out, _ = process.communicate() |
| 20 | + if out: |
| 21 | + version += out.decode("utf-8").strip() |
| 22 | + |
| 23 | + process = subprocess.Popen(["git", "rev-parse", "--short", "HEAD"], stdout=subprocess.PIPE) |
| 24 | + out, _ = process.communicate() |
| 25 | + if out: |
| 26 | + version += "+g" + out.decode("utf-8").strip() |
| 27 | + except (Exception) as e: |
| 28 | + pass |
| 29 | + |
| 30 | +release = version |
11 | 31 |
|
12 | 32 |
|
13 | 33 | extensions = [ |
|
19 | 39 | ] |
20 | 40 |
|
21 | 41 |
|
22 | | -html_theme = "sphinx_rtd_theme" |
23 | | - |
24 | 42 | autodoc_typehints = "none" |
| 43 | + |
25 | 44 | intersphinx_mapping = { |
26 | 45 | "aiohttp": ("https://docs.aiohttp.org/en/stable/", None), |
27 | 46 | "python": ("https://docs.python.org/3", None), |
28 | 47 | "discord": ("https://discordpy.readthedocs.io/en/latest", None), |
29 | 48 | } |
30 | 49 |
|
31 | 50 | highlight_language = "python3" |
| 51 | +html_theme = "sphinx_rtd_theme" |
32 | 52 | master_doc = "index" |
33 | 53 | pygments_style = "friendly" |
34 | 54 | source_suffix = ".rst" |
0 commit comments