Skip to content

Commit ac32af9

Browse files
authored
Fix docs dependencies spec, resolve docs version automatically (#180)
Proof it works: ```py >>> from docs import conf >>> conf.version '2.1' >>> conf.release '2.1.0' ```
2 parents 361e5a8 + 9493671 commit ac32af9

4 files changed

Lines changed: 109 additions & 76 deletions

File tree

.readthedocs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ python:
1212
install:
1313
- method: pip
1414
path: .
15+
extra_requirements:
16+
- docs

docs/conf.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
1+
import datetime as dt
12
import os
3+
import re
24
import sys
3-
import datetime as dt
5+
from pathlib import Path
6+
7+
MATCH_VERSION_LINE = re.compile(r"version = \W((\d+\.\d+)\.\d.*?)\W").fullmatch
48

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()
514

615
sys.path.insert(0, os.path.abspath(".."))
716

817
extensions = [
9-
'sphinx.ext.autodoc',
10-
'sphinx.ext.intersphinx',
11-
'sphinx.ext.viewcode',
12-
'sphinx.ext.autosectionlabel',
13-
'sphinx_rtd_theme',
18+
"sphinx.ext.autodoc",
19+
"sphinx.ext.intersphinx",
20+
"sphinx.ext.viewcode",
21+
"sphinx.ext.autosectionlabel",
22+
"sphinx_rtd_theme",
1423
]
15-
source_suffix = '.rst'
16-
master_doc = 'index'
17-
18-
project = u'Confuse'
19-
copyright = '2012-{}, Adrian Sampson & contributors'.format(
20-
dt.date.today().year
21-
)
24+
source_suffix = ".rst"
25+
master_doc = "index"
2226

23-
version = '1.7'
24-
release = '1.7.0'
27+
project = "Confuse"
28+
copyright = "2012-{}, Adrian Sampson & contributors".format(dt.date.today().year)
2529

26-
exclude_patterns = ['_build']
30+
exclude_patterns = ["_build"]
2731

28-
pygments_style = 'sphinx'
32+
pygments_style = "sphinx"
2933

3034
# -- Options for HTML output --------------------------------------------------
3135

32-
html_theme = 'sphinx_rtd_theme'
33-
htmlhelp_basename = 'Confusedoc'
36+
html_theme = "sphinx_rtd_theme"
37+
htmlhelp_basename = "Confusedoc"

0 commit comments

Comments
 (0)