Skip to content

Commit da45e7e

Browse files
committed
Display changelog for unreleased version in docs
1 parent 3603b28 commit da45e7e

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

docs/conf.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
from functools import partial
2+
from pathlib import Path
3+
4+
from setuptools_scm import get_version
5+
6+
17
extensions = ['sphinx.ext.autodoc', 'jaraco.packaging.sphinx', 'rst.linker']
28

39
master_doc = "index"
@@ -99,3 +105,27 @@
99105

100106
# Add support for inline tabs
101107
extensions += ['sphinx_inline_tabs']
108+
109+
# Add support for the unreleased "next-version" change notes
110+
extensions += ['sphinxcontrib.towncrier']
111+
112+
113+
# -- Options for towncrier_draft extension --------------------------------------------
114+
115+
PROJECT_ROOT_DIR = Path(__file__).parents[1].resolve()
116+
get_scm_version = partial(get_version, root=PROJECT_ROOT_DIR)
117+
118+
# The short X.Y version
119+
version = '.'.join(
120+
get_scm_version(
121+
local_scheme='no-local-version',
122+
).split('.')[:3],
123+
)
124+
125+
# The full version, including alpha/beta/rc tags
126+
release = get_scm_version()
127+
128+
towncrier_draft_autoversion_mode = "draft" # or: 'sphinx-release', 'sphinx-version'
129+
towncrier_draft_include_empty = True
130+
towncrier_draft_working_directory = PROJECT_ROOT_DIR
131+
# Not yet supported: towncrier_draft_config_path = 'pyproject.toml' # relative to cwd

docs/history.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
History
66
*******
77

8+
.. towncrier-draft-entries:: |release|, unreleased as on |today|
9+
810
.. include:: ../CHANGES (links).rst
911

1012
Credits

pytest.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ filterwarnings=
2121
# https://github.com/pypa/setuptools/issues/2081
2222
ignore:lib2to3 package is deprecated:PendingDeprecationWarning
2323
ignore:lib2to3 package is deprecated:DeprecationWarning
24+
25+
# Having setuptools_scm in docs/conf.py causes this because pytest, besides
26+
# running tests also runs linters. But since GitHub Actions CI/CD workflows
27+
# do not perform full checkouts by default, the Git clone in that env is
28+
# shallow:
29+
ignore:"/home/runner/work/setuptools/setuptools" is shallow and may cause errors:UserWarning:setuptools_scm.git

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ docs =
7474

7575
# local
7676
pygments-github-lexers==0.0.5
77+
setuptools-scm
7778
sphinx-inline-tabs
79+
sphinxcontrib-towncrier
7880

7981
ssl =
8082
wincertstore==0.2; sys_platform=='win32'

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tox_pip_extensions_ext_venv_update = true
66
toxworkdir={env:TOX_WORK_DIR:.tox}
77

88
[testenv]
9-
deps =
9+
deps = setuptools-scm
1010
commands =
1111
pytest {posargs}
1212
usedevelop = True

0 commit comments

Comments
 (0)