Skip to content

Commit ca4be61

Browse files
committed
docs: add docs-draft tox env, with generated towncrier draft
1 parent 9d90093 commit ca4be61

File tree

5 files changed

+51
-2
lines changed

5 files changed

+51
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ src/_pytest/_version.py
2525

2626
doc/*/_build
2727
doc/*/.doctrees
28+
doc/*/_changelog_towncrier_draft.rst
2829
build/
2930
dist/
3031
*.egg-info

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
- stage: baseline
6666
env: TOXENV=py36-xdist
6767
python: '3.6'
68-
- env: TOXENV=linting,docs,doctesting PYTEST_COVERAGE=1
68+
- env: TOXENV=linting,docs-draft,doctesting PYTEST_COVERAGE=1
6969
cache:
7070
directories:
7171
- $HOME/.cache/pre-commit

doc/en/changelog.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11

22
.. _changelog:
33

4+
.. only:: changelog_towncrier_draft
5+
6+
==============================
7+
Draft changelog from towncrier
8+
==============================
9+
10+
.. include:: _changelog_towncrier_draft.rst
11+
12+
**End of DRAFT changelog**
13+
14+
------------
15+
416
.. include:: ../../CHANGELOG.rst

doc/en/conf.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
from _pytest import __version__ as version
2222

23+
if False: # TYPE_CHECKING
24+
import sphinx.application
25+
26+
2327
release = ".".join(version.split(".")[:2])
2428

2529
# If extensions (or modules to document with autodoc) are in another directory,
@@ -342,7 +346,27 @@
342346
intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
343347

344348

345-
def setup(app):
349+
def configure_logging(app: "sphinx.application.Sphinx") -> None:
350+
"""Configure Sphinx's WarningHandler to handle (expected) missing include."""
351+
import sphinx.util.logging
352+
import logging
353+
354+
class WarnLogFilter(logging.Filter):
355+
def filter(self, record: logging.LogRecord) -> bool:
356+
if (
357+
record.msg.startswith('Problems with "include" directive path:')
358+
and "_changelog_towncrier_draft.rst" in record.msg
359+
):
360+
return False
361+
return True
362+
363+
logger = logging.getLogger(sphinx.util.logging.NAMESPACE)
364+
warn_handler = [x for x in logger.handlers if x.level == logging.WARNING]
365+
assert len(warn_handler) == 1, warn_handler
366+
warn_handler[0].filters.insert(0, WarnLogFilter())
367+
368+
369+
def setup(app: "sphinx.application.Sphinx") -> None:
346370
# from sphinx.ext.autodoc import cut_lines
347371
# app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
348372
app.add_object_type(
@@ -351,3 +375,4 @@ def setup(app):
351375
objname="configuration value",
352376
indextemplate="pair: %s; configuration value",
353377
)
378+
configure_logging(app)

tox.ini

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ deps = -r{toxinidir}/doc/en/requirements.txt
6363
commands =
6464
sphinx-build -W --keep-going -b html . _build {posargs:}
6565

66+
[testenv:docs-draft]
67+
basepython = python3
68+
usedevelop = True
69+
deps =
70+
-r{toxinidir}/doc/en/requirements.txt
71+
towncrier
72+
whitelist_externals = sh
73+
commands =
74+
sh -c 'towncrier --draft > doc/en/_changelog_towncrier_draft.rst'
75+
sphinx-build -W --keep-going -b html doc/en doc/en/_build -t changelog_towncrier_draft {posargs:}
76+
6677
[testenv:docs-checklinks]
6778
basepython = python3
6879
usedevelop = True

0 commit comments

Comments
 (0)