docs: move changelog to docs/en and allow sphinx directives

Now `tox -e docs` will also include the draft changelog for the
next version (locally only).

`CHANGELOG.rst` now only points to the changelog on READTHEDOCS so
sphinx diretives can be used.

Followup to https://github.com/pytest-dev/pytest/pull/6272
This commit is contained in:
Daniel Hahler 2019-11-25 04:06:30 +01:00 committed by Bruno Oliveira
parent 209d99102d
commit d3ab56f531
10 changed files with 7620 additions and 7563 deletions

1
.gitignore vendored
View File

@ -25,6 +25,7 @@ src/_pytest/_version.py
doc/*/_build doc/*/_build
doc/*/.doctrees doc/*/.doctrees
doc/*/_changelog_towncrier_draft.rst
build/ build/
dist/ dist/
*.egg-info *.egg-info

View File

@ -48,7 +48,7 @@ repos:
- id: rst - id: rst
name: rst name: rst
entry: rst-lint --encoding utf-8 entry: rst-lint --encoding utf-8
files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst|TIDELIFT.rst|changelog/.*)$ files: ^(HOWTORELEASE.rst|README.rst|TIDELIFT.rst)$
language: python language: python
additional_dependencies: [pygments, restructuredtext_lint] additional_dependencies: [pygments, restructuredtext_lint]
- id: changelogs-rst - id: changelogs-rst

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,7 @@ changelog using that instead.
If you are not sure what issue type to use, don't hesitate to ask in your PR. If you are not sure what issue type to use, don't hesitate to ask in your PR.
``towncrier`` preserves multiple paragraphs and formatting (code blocks, lists, and so on), but for entries ``towncrier`` preserves multiple paragraphs and formatting (code blocks, lists, and so on), but for entries
other than ``features`` it is usually better to stick to a single paragraph to keep it concise. You can install other than ``features`` it is usually better to stick to a single paragraph to keep it concise.
``towncrier`` and then run ``towncrier --draft``
if you want to get a preview of how your change will look in the final release notes. You can also run ``tox -e docs`` to build the documentation
with the draft changelog (``doc/en/_build/changelog.html``) if you want to get a preview of how your change will look in the final release notes.

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,10 @@ import sys
from _pytest import __version__ as version from _pytest import __version__ as version
if False: # TYPE_CHECKING
import sphinx.application
release = ".".join(version.split(".")[:2]) release = ".".join(version.split(".")[:2])
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
@ -342,7 +346,30 @@ texinfo_documents = [
intersphinx_mapping = {"python": ("https://docs.python.org/3", None)} intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
def setup(app): def configure_logging(app: "sphinx.application.Sphinx") -> None:
"""Configure Sphinx's WarningHandler to handle (expected) missing include."""
import sphinx.util.logging
import logging
class WarnLogFilter(logging.Filter):
def filter(self, record: logging.LogRecord) -> bool:
"""Ignore warnings about missing include with "only" directive.
Ref: https://github.com/sphinx-doc/sphinx/issues/2150."""
if (
record.msg.startswith('Problems with "include" directive path:')
and "_changelog_towncrier_draft.rst" in record.msg
):
return False
return True
logger = logging.getLogger(sphinx.util.logging.NAMESPACE)
warn_handler = [x for x in logger.handlers if x.level == logging.WARNING]
assert len(warn_handler) == 1, warn_handler
warn_handler[0].filters.insert(0, WarnLogFilter())
def setup(app: "sphinx.application.Sphinx") -> None:
# from sphinx.ext.autodoc import cut_lines # from sphinx.ext.autodoc import cut_lines
# app.connect('autodoc-process-docstring', cut_lines(4, what=['module'])) # app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
app.add_object_type( app.add_object_type(
@ -351,3 +378,4 @@ def setup(app):
objname="configuration value", objname="configuration value",
indextemplate="pair: %s; configuration value", indextemplate="pair: %s; configuration value",
) )
configure_logging(app)

View File

@ -463,6 +463,8 @@ monkeypatch
.. autoclass:: _pytest.monkeypatch.MonkeyPatch .. autoclass:: _pytest.monkeypatch.MonkeyPatch
:members: :members:
.. _testdir:
testdir testdir
~~~~~~~ ~~~~~~~

View File

@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
[tool.towncrier] [tool.towncrier]
package = "pytest" package = "pytest"
package_dir = "src" package_dir = "src"
filename = "CHANGELOG.rst" filename = "doc/en/changelog.rst"
directory = "changelog/" directory = "changelog/"
title_format = "pytest {version} ({project_date})" title_format = "pytest {version} ({project_date})"
template = "changelog/_template.rst" template = "changelog/_template.rst"

View File

@ -85,13 +85,14 @@ def check_links():
check_call(["tox", "-e", "docs-checklinks"]) check_call(["tox", "-e", "docs-checklinks"])
def pre_release(version): def pre_release(version, *, skip_check_links):
"""Generates new docs, release announcements and creates a local tag.""" """Generates new docs, release announcements and creates a local tag."""
announce(version) announce(version)
regen() regen()
changelog(version, write_out=True) changelog(version, write_out=True)
fix_formatting() fix_formatting()
check_links() if not skip_check_links:
check_links()
msg = "Preparing release version {}".format(version) msg = "Preparing release version {}".format(version)
check_call(["git", "commit", "-a", "-m", msg]) check_call(["git", "commit", "-a", "-m", msg])
@ -114,8 +115,9 @@ def main():
init(autoreset=True) init(autoreset=True)
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("version", help="Release version") parser.add_argument("version", help="Release version")
parser.add_argument("--skip-check-links", action="store_true", default=False)
options = parser.parse_args() options = parser.parse_args()
pre_release(options.version) pre_release(options.version, skip_check_links=options.skip_check_links)
if __name__ == "__main__": if __name__ == "__main__":

18
tox.ini
View File

@ -58,10 +58,16 @@ commands = pre-commit run --all-files --show-diff-on-failure
[testenv:docs] [testenv:docs]
basepython = python3 basepython = python3
usedevelop = True usedevelop = True
changedir = doc/en deps =
deps = -r{toxinidir}/doc/en/requirements.txt -r{toxinidir}/doc/en/requirements.txt
towncrier
whitelist_externals = sh
commands = commands =
sphinx-build -W --keep-going -b html . _build {posargs:} sh -c 'towncrier --draft > doc/en/_changelog_towncrier_draft.rst'
# the '-t changelog_towncrier_draft' tags makes sphinx include the draft
# changelog in the docs; this does not happen on ReadTheDocs because it uses
# the standard sphinx command so the 'changelog_towncrier_draft' is never set there
sphinx-build -W --keep-going -b html doc/en doc/en/_build -t changelog_towncrier_draft {posargs:}
[testenv:docs-checklinks] [testenv:docs-checklinks]
basepython = python3 basepython = python3
@ -86,10 +92,10 @@ changedir = doc/en
skipsdist = True skipsdist = True
basepython = python3 basepython = python3
deps = deps =
sphinx dataclasses
PyYAML PyYAML
regendoc>=0.6.1 regendoc>=0.6.1
dataclasses sphinx
whitelist_externals = whitelist_externals =
rm rm
make make
@ -117,8 +123,8 @@ deps =
colorama colorama
gitpython gitpython
pre-commit>=1.11.0 pre-commit>=1.11.0
towncrier
wheel wheel
towncrier
commands = python scripts/release.py {posargs} commands = python scripts/release.py {posargs}
[testenv:publish_gh_release_notes] [testenv:publish_gh_release_notes]