Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ src/_pytest/_version.py

doc/*/_build
doc/*/.doctrees
doc/*/_changelog_towncrier_draft.rst
build/
dist/
*.egg-info
Expand Down
4 changes: 4 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ build:
3.12
apt_packages:
- inkscape
jobs:
post_checkout:
- git fetch --unshallow || true
- git fetch --tags || true

formats:
- epub
Expand Down
11 changes: 7 additions & 4 deletions doc/en/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ with advance notice in the **Deprecations** section of releases.
we named the news folder changelog


.. only:: changelog_towncrier_draft
.. only:: not is_release

.. The 'changelog_towncrier_draft' tag is included by our 'tox -e docs',
but not on readthedocs.
To be included in v\ |release| (if present)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. include:: _changelog_towncrier_draft.rst
.. towncrier-draft-entries:: |release| [UNRELEASED DRAFT]

Released versions
^^^^^^^^^^^^^^^^^

.. towncrier release notes start

Expand Down
46 changes: 20 additions & 26 deletions doc/en/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#
# The full version, including alpha/beta/rc tags.
# The short X.Y version.
import os
from pathlib import Path
import shutil
from textwrap import dedent
from typing import TYPE_CHECKING
Expand All @@ -26,6 +28,16 @@
import sphinx.application


PROJECT_ROOT_DIR = Path(__file__).parents[2].resolve()
IS_RELEASE_ON_RTD = (
os.getenv("READTHEDOCS", "False") == "True"
and os.environ["READTHEDOCS_VERSION_TYPE"] == "tag"
)
if IS_RELEASE_ON_RTD:
tags: set[str]
# pylint: disable-next=used-before-assignment
tags.add("is_release") # noqa: F821

release = ".".join(version.split(".")[:2])

# If extensions (or modules to document with autodoc) are in another directory,
Expand Down Expand Up @@ -72,6 +84,7 @@
"sphinx.ext.viewcode",
"sphinx_removed_in",
"sphinxcontrib_trio",
"sphinxcontrib.towncrier.ext", # provides `towncrier-draft-entries` directive
]

# Building PDF docs on readthedocs requires inkscape for svg to pdf
Expand Down Expand Up @@ -422,6 +435,13 @@
)
]

# -- Options for towncrier_draft extension -----------------------------------

towncrier_draft_autoversion_mode = "draft" # or: 'sphinx-version', 'sphinx-release'
towncrier_draft_include_empty = True
towncrier_draft_working_directory = PROJECT_ROOT_DIR
towncrier_draft_config_path = "pyproject.toml" # relative to cwd


intersphinx_mapping = {
"pluggy": ("https://pluggy.readthedocs.io/en/stable", None),
Expand All @@ -435,30 +455,6 @@
}


def configure_logging(app: "sphinx.application.Sphinx") -> None:
"""Configure Sphinx's WarningHandler to handle (expected) missing include."""
import logging

import sphinx.util.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:
app.add_crossref_type(
"fixture",
Expand Down Expand Up @@ -488,8 +484,6 @@ def setup(app: "sphinx.application.Sphinx") -> None:
indextemplate="pair: %s; hook",
)

configure_logging(app)

# legacypath.py monkey-patches pytest.Testdir in. Import the file so
# that autodoc can discover references to it.
import _pytest.legacypath # noqa: F401
1 change: 1 addition & 0 deletions doc/en/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ sphinxcontrib-svg2pdfconverter
# See https://github.com/pytest-dev/pytest/pull/10578#issuecomment-1348249045.
packaging
furo
sphinxcontrib-towncrier
18 changes: 0 additions & 18 deletions scripts/towncrier-draft-to-file.py

This file was deleted.

10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ deps =
# https://github.com/twisted/towncrier/issues/340
towncrier<21.3.0
commands =
python scripts/towncrier-draft-to-file.py
# 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/html -t changelog_towncrier_draft {posargs:}
# Retrieve possibly missing commits:
-git fetch --unshallow
-git fetch --tags

sphinx-build -W --keep-going -b html doc/en doc/en/_build/html {posargs:}
setenv =
# Sphinx is not clean of this warning.
PYTHONWARNDEFAULTENCODING=
Expand Down