Skip to content

Commit

Permalink
Merge branch 'master' into issue-11233/linkcheck-redirect-support-for…
Browse files Browse the repository at this point in the history
…-ignore-urls
  • Loading branch information
jayaddison authored Nov 24, 2024
2 parents c3c639c + b6b01c2 commit 4e21c08
Show file tree
Hide file tree
Showing 136 changed files with 332 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,4 @@ jobs:
env:
VIRTUALENV_SYSTEM_SITE_PACKAGES: "1"
- name: codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
9 changes: 6 additions & 3 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ select = [
[lint.per-file-ignores]
"doc/*" = [
"ANN", # documentation doesn't need annotations
"TCH001", # documentation doesn't need type-checking blocks
"TC001", # documentation doesn't need type-checking blocks
]
"doc/conf.py" = ["INP001", "W605"]
"doc/development/tutorials/examples/*" = ["INP001"]
"doc/development/tutorials/examples/*" = ["I002", "INP001"]
# allow print() in the tutorial
"doc/development/tutorials/examples/recipe.py" = [
"FURB118",
Expand Down Expand Up @@ -360,7 +360,7 @@ select = [

# these tests need old ``typing`` generic aliases
"tests/test_util/test_util_typing.py" = ["UP006", "UP007", "UP035"]
"tests/test_util/typing_test_data.py" = ["FA100", "PYI030", "UP006", "UP007", "UP035"]
"tests/test_util/typing_test_data.py" = ["FA100", "I002", "PYI030", "UP006", "UP007", "UP035"]

"utils/*" = [
"T201", # whitelist ``print`` for stdout messages
Expand All @@ -377,6 +377,9 @@ inline-quotes = "single"
forced-separate = [
"tests",
]
required-imports = [
"from __future__ import annotations",
]

[format]
preview = true
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Bugs fixed

* #13060: HTML Search: use ``Map`` to store per-file term scores.
Patch by James Addison
* LaTeX: fix a ``7.4.0`` typo in a default for ``\sphinxboxsetup``
(refs: PR #13152).
Patch by Jean-François B.
* #11233: linkcheck: match redirect URIs against :confval:`linkcheck_ignore` by
overriding session-level ``requests.get_redirect_target``.

Expand Down
4 changes: 2 additions & 2 deletions doc/man/sphinx-build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Options
.. versionchanged:: 6.2
Add ``--jobs`` long option.

.. option:: -c path, --config-dir path
.. option:: -c path, --conf-dir path

Don't look for the :file:`conf.py` in the source directory, but use the given
configuration directory instead. Note that various other files and paths
Expand All @@ -152,7 +152,7 @@ Options
.. versionadded:: 0.3

.. versionchanged:: 7.3
Add ``--config-dir`` long option.
Add ``--conf-dir`` long option.

.. option:: -C, --isolated

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ docs = [
]
lint = [
"flake8>=6.0",
"ruff==0.7.3",
"ruff==0.8.0",
"mypy==1.13.0",
"sphinx-lint>=0.9",
"types-colorama==0.4.15.20240311",
Expand Down
2 changes: 2 additions & 0 deletions sphinx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""The Sphinx documentation toolchain."""

from __future__ import annotations

__version__ = '8.2.0'
__display_version__ = __version__ # used for command line version

Expand Down
2 changes: 2 additions & 0 deletions sphinx/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""The Sphinx documentation toolchain."""

from __future__ import annotations

import sys

from sphinx.cmd.build import main
Expand Down
2 changes: 1 addition & 1 deletion sphinx/_cli/util/colour.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
import sys
from collections.abc import Callable # NoQA: TCH003
from collections.abc import Callable # NoQA: TC003

if sys.platform == 'win32':
import colorama
Expand Down
2 changes: 1 addition & 1 deletion sphinx/builders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Builder:
# doctree versioning method
versioning_method = 'none'
versioning_compare = False
#: Whether it is safe to make parallel :meth:`~.Builder.write_doc()` calls.
#: Whether it is safe to make parallel :meth:`~.Builder.write_doc` calls.
allow_parallel: bool = False
# support translation
use_message_catalog = True
Expand Down
5 changes: 1 addition & 4 deletions sphinx/builders/changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ def write_documents(self, _docnames: Set[str]) -> None:
return
logger.info(bold(__('writing summary file...')))
for changeset in changesets:
if isinstance(changeset.descname, tuple):
descname = changeset.descname[0]
else:
descname = changeset.descname
descname = changeset.descname
ttext = self.typemap[changeset.type]
context = changeset.content.replace('\n', ' ')
if descname and changeset.docname.startswith('c-api'):
Expand Down
2 changes: 2 additions & 0 deletions sphinx/builders/latex/nodes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Additional nodes for LaTeX writer."""

from __future__ import annotations

from docutils import nodes


Expand Down
12 changes: 8 additions & 4 deletions sphinx/directives/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from docutils.parsers.rst import directives, roles

from sphinx import addnodes
from sphinx.addnodes import desc_signature # NoQA: TCH001
from sphinx.addnodes import desc_signature # NoQA: TC001
from sphinx.util import docutils
from sphinx.util.docfields import DocFieldTransformer, Field, TypedField
from sphinx.util.docutils import SphinxDirective
from sphinx.util.typing import ExtensionMetadata, OptionSpec # NoQA: TCH001
from sphinx.util.typing import ExtensionMetadata, OptionSpec # NoQA: TC001

if TYPE_CHECKING:
from docutils.nodes import Node
Expand Down Expand Up @@ -282,7 +282,11 @@ def run(self) -> list[Node]:

if self.names:
# needed for association of version{added,changed} directives
self.env.temp_data['object'] = self.names[0]
object_name: ObjDescT = self.names[0]
if isinstance(object_name, tuple):
self.env.temp_data['object'] = str(object_name[0])
else:
self.env.temp_data['object'] = str(object_name)
self.before_content()
content_children = self.parse_content_to_nodes(allow_section_headings=True)
content_node = addnodes.desc_content('', *content_children)
Expand All @@ -292,7 +296,7 @@ def run(self) -> list[Node]:
'object-description-transform', self.domain, self.objtype, content_node
)
DocFieldTransformer(self).transform_all(content_node)
self.env.temp_data['object'] = None
self.env.temp_data['object'] = ''
self.after_content()

if node['no-typesetting']:
Expand Down
3 changes: 3 additions & 0 deletions sphinx/domains/c/_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def __str__(self) -> str:
def get_display_string(self) -> str:
return "[anonymous]" if self.is_anonymous else self.name

def _stringify(self, transform: StringifyTransform) -> str:
return transform(self.get_display_string())

def describe_signature(self, signode: TextElement, mode: str, env: BuildEnvironment,
prefix: str, symbol: Symbol) -> None:
# note: slightly different signature of describe_signature due to the prefix
Expand Down
4 changes: 2 additions & 2 deletions sphinx/domains/changeset.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ChangeSet(NamedTuple):
docname: str
lineno: int
module: str | None
descname: str | None
descname: str
content: str


Expand Down Expand Up @@ -123,7 +123,7 @@ def changesets(self) -> dict[str, list[ChangeSet]]:
def note_changeset(self, node: addnodes.versionmodified) -> None:
version = node['version']
module = self.env.ref_context.get('py:module')
objname = self.env.temp_data.get('object')
objname = self.env.temp_data.get('object', '')
changeset = ChangeSet(node['type'], self.env.docname, node.line, # type: ignore[arg-type]
module, objname, node.astext())
self.changesets.setdefault(version, []).append(changeset)
Expand Down
8 changes: 7 additions & 1 deletion sphinx/environment/adapters/asset.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
"""Assets adapter for sphinx.environment."""

from sphinx.environment import BuildEnvironment
from __future__ import annotations

from typing import TYPE_CHECKING

from sphinx.util._pathlib import _StrPath

if TYPE_CHECKING:
from sphinx.environment import BuildEnvironment


class ImageAdapter:
def __init__(self, env: BuildEnvironment) -> None:
Expand Down
2 changes: 2 additions & 0 deletions sphinx/ext/intersphinx/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Command line interface for the intersphinx extension."""

from __future__ import annotations

import logging as _logging
import sys

Expand Down
4 changes: 2 additions & 2 deletions sphinx/ext/viewcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def _get_full_modname(modname: str, attribute: str) -> str | None:
return getattr(value, '__module__', None)
except AttributeError:
# sphinx.ext.viewcode can't follow class instance attribute
# then AttributeError logging output only verbose mode.
logger.verbose("Didn't find %s in %s", attribute, modname)
# then AttributeError logging output only debug mode.
logger.debug("Didn't find %s in %s", attribute, modname)
return None
except Exception as e:
# sphinx.ext.viewcode follow python domain directives.
Expand Down
2 changes: 2 additions & 0 deletions sphinx/pygments_styles.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Sphinx theme specific highlighting styles."""

from __future__ import annotations

from pygments.style import Style
from pygments.styles.friendly import FriendlyStyle
from pygments.token import (
Expand Down
11 changes: 9 additions & 2 deletions sphinx/testing/restructuredtext.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
from docutils import nodes
from __future__ import annotations

from typing import TYPE_CHECKING

from docutils.core import publish_doctree

from sphinx.application import Sphinx
from sphinx.io import SphinxStandaloneReader
from sphinx.parsers import RSTParser
from sphinx.util.docutils import sphinx_domains

if TYPE_CHECKING:
from docutils import nodes

from sphinx.application import Sphinx


def parse(app: Sphinx, text: str, docname: str = 'index') -> nodes.document:
"""Parse a string as reStructuredText with Sphinx application."""
Expand Down
7 changes: 4 additions & 3 deletions sphinx/texinputs/sphinx.sty
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
% by the Sphinx LaTeX writer.

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sphinx}[2024/10/11 v8.1.1 Sphinx LaTeX package (sphinx-doc)]
\ProvidesPackage{sphinx}[2024/11/23 v8.2.0 Sphinx LaTeX package (sphinx-doc)]

% provides \ltx@ifundefined
% (many packages load ltxcmds: graphicx does for pdftex and lualatex but
Expand Down Expand Up @@ -1098,12 +1098,13 @@
% Some of these defaults got already set. But we now list them all explicitly
% for a complete initial configuration of reset storage.
% At 7.4.0, \fboxrule and \fboxsep replaced by 0.4pt and 3pt which are anyhow
% the defaults for these LaTeX dimensions.
% the defaults for these LaTeX dimensions. 8.2.0 corrected border-radius
% default back to 3pt (\fboxsep) not 0.4pt (\fboxrule).
\let\spx@boxes@sphinxbox@defaults\@gobble
\sphinxboxsetup{%
border-width=0.4pt,
padding=3pt,
border-radius=0.4pt,
border-radius=3pt,
box-shadow=none,
% MEMO: as xcolor is loaded, \spx@defineorletcolor has a "\colorlet" branch
% which makes this syntax acceptable and avoids duplicating here the values.
Expand Down
3 changes: 3 additions & 0 deletions sphinx/util/_lines.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import annotations


def parse_line_num_spec(spec: str, total: int) -> list[int]:
"""Parse a line number spec (such as "1,2,4-6") and return a list of
wanted line numbers.
Expand Down
2 changes: 2 additions & 0 deletions sphinx/util/build_phase.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Build phase of Sphinx application."""

from __future__ import annotations

from enum import IntEnum


Expand Down
6 changes: 4 additions & 2 deletions sphinx/util/cfamily.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def clone(self) -> Any:
return deepcopy(self)

def _stringify(self, transform: StringifyTransform) -> str:
raise NotImplementedError(repr(self))
raise NotImplementedError

def __str__(self) -> str:
return self._stringify(str)
Expand All @@ -124,7 +124,9 @@ def get_display_string(self) -> str:
return self._stringify(lambda ast: ast.get_display_string())

def __repr__(self) -> str:
return f'<{self.__class__.__name__}: {self._stringify(repr)}>'
if repr_string := self._stringify(repr):
return f'<{self.__class__.__name__}: {repr_string}>'
return f'<{self.__class__.__name__}>'


################################################################################
Expand Down
6 changes: 3 additions & 3 deletions sphinx/util/docutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
import re
from collections.abc import Sequence # NoQA: TCH003
from collections.abc import Sequence # NoQA: TC003
from contextlib import contextmanager
from copy import copy
from pathlib import Path
Expand All @@ -14,7 +14,7 @@
from docutils import nodes
from docutils.io import FileOutput
from docutils.parsers.rst import Directive, directives, roles
from docutils.parsers.rst.states import Inliner # NoQA: TCH002
from docutils.parsers.rst.states import Inliner # NoQA: TC002
from docutils.statemachine import State, StateMachine, StringList
from docutils.utils import Reporter, unescape

Expand All @@ -29,7 +29,7 @@
)

if TYPE_CHECKING:
from collections.abc import Callable, Iterator # NoQA: TCH003
from collections.abc import Callable, Iterator # NoQA: TC003
from types import ModuleType, TracebackType

from docutils.frontend import Values
Expand Down
2 changes: 2 additions & 0 deletions sphinx/util/http_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Reference: https://www.rfc-editor.org/rfc/rfc7231#section-7.1.1.1
"""

from __future__ import annotations

import time
import warnings
from email.utils import parsedate_tz
Expand Down
2 changes: 2 additions & 0 deletions tests/test_builders/test_build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Test all builders."""

from __future__ import annotations

import os
import shutil
from contextlib import contextmanager
Expand Down
2 changes: 2 additions & 0 deletions tests/test_builders/test_build_changes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Test the ChangesBuilder class."""

from __future__ import annotations

import pytest


Expand Down
2 changes: 2 additions & 0 deletions tests/test_builders/test_build_dirhtml.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Test dirhtml builder."""

from __future__ import annotations

import posixpath

import pytest
Expand Down
2 changes: 2 additions & 0 deletions tests/test_builders/test_build_epub.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Test the HTML builder and check output against XPath."""

from __future__ import annotations

import os
import subprocess
import xml.etree.ElementTree as ET
Expand Down
2 changes: 2 additions & 0 deletions tests/test_builders/test_build_gettext.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Test the build process with gettext builder with the test root."""

from __future__ import annotations

import gettext
import re
import subprocess
Expand Down
Loading

0 comments on commit 4e21c08

Please sign in to comment.