Skip to content

Commit 9493671

Browse files
committed
Resolve docs version/release automatically
1 parent cb0ef54 commit 9493671

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

docs/conf.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import datetime as dt
22
import os
3+
import re
34
import sys
5+
from pathlib import Path
6+
7+
MATCH_VERSION_LINE = re.compile(r"version = \W((\d+\.\d+)\.\d.*?)\W").fullmatch
8+
9+
pyproject = Path(__file__).parent.parent / "pyproject.toml"
10+
version_line_match = next(
11+
filter(None, map(MATCH_VERSION_LINE, pyproject.read_text().splitlines()))
12+
)
13+
release, version = version_line_match.groups()
414

515
sys.path.insert(0, os.path.abspath(".."))
616

@@ -17,9 +27,6 @@
1727
project = "Confuse"
1828
copyright = "2012-{}, Adrian Sampson & contributors".format(dt.date.today().year)
1929

20-
version = "2.1"
21-
release = "2.1.1"
22-
2330
exclude_patterns = ["_build"]
2431

2532
pygments_style = "sphinx"

0 commit comments

Comments
 (0)