Merge branch '5.2.x' into 5.x

# Conflicts:
#	CHANGES
#	sphinx/__init__.py
This commit is contained in:
Adam Turner 2022-09-27 15:58:00 +01:00
commit 8accc34966
7 changed files with 24 additions and 15 deletions

View File

@ -19,7 +19,13 @@ Bugs fixed
Testing
--------
Release 5.2.1 (released Sep 24, 2022)
Release 5.2.2 (released Sep 27, 2022)
=====================================
* #10872: Restore link targets for autodoc modules to the top of content.
Patch by Dominic Davis-Foster.
Release 5.2.1 (released Sep 25, 2022)
=====================================
Bugs fixed

View File

@ -87,7 +87,7 @@ lint = [
"flake8-bugbear",
"flake8-simplify",
"isort",
"mypy>=0.971",
"mypy>=0.981",
"sphinx-lint",
"docutils-stubs",
"types-typed-ast",

View File

@ -298,7 +298,7 @@ class JSModule(SphinxDirective):
content_node.document = self.state.document
nested_parse_with_titles(self.state, self.content, content_node)
ret: List[Node] = [*content_node.children]
ret: List[Node] = []
if not noindex:
domain = cast(JavaScriptDomain, self.env.get_domain('js'))
@ -315,6 +315,7 @@ class JSModule(SphinxDirective):
indextext = _('%s (module)') % mod_name
inode = addnodes.index(entries=[('single', indextext, node_id, '', None)])
ret.append(inode)
ret.extend(content_node.children)
return ret
def make_old_id(self, modname: str) -> str:

View File

@ -1024,7 +1024,7 @@ class PyModule(SphinxDirective):
content_node.document = self.state.document
nested_parse_with_titles(self.state, self.content, content_node)
ret: List[Node] = [*content_node.children]
ret: List[Node] = []
if not noindex:
# note module to the domain
node_id = make_id(self.env, self.state.document, 'module', modname)
@ -1045,6 +1045,7 @@ class PyModule(SphinxDirective):
indextext = '%s; %s' % (pairindextypes['module'], modname)
inode = addnodes.index(entries=[('pair', indextext, node_id, '', None)])
ret.append(inode)
ret.extend(content_node.children)
return ret
def make_old_id(self, name: str) -> str:

View File

@ -47,7 +47,7 @@ class GenericObject(ObjectDescription[str]):
A generic x-ref directive registered with Sphinx.add_object_type().
"""
indextemplate: str = ''
parse_node: Callable[["GenericObject", "BuildEnvironment", str, desc_signature], str] = None # NOQA
parse_node: Callable[["BuildEnvironment", str, desc_signature], str] = None # NOQA
def handle_signature(self, sig: str, signode: desc_signature) -> str:
if self.parse_node:

View File

@ -19,10 +19,11 @@ from sphinx.util import logging
logger = logging.getLogger(__name__)
if sys.platform != "win32":
ForkContext = multiprocessing.context.ForkContext
ForkProcess = multiprocessing.context.ForkProcess
else:
# For static typing, as ForkProcess doesn't exist on Windows
ForkProcess = multiprocessing.process.BaseProcess
ForkContext = ForkProcess = Any
# our parallel functionality only works for the forking Process
parallel_available = multiprocessing and os.name == 'posix'
@ -92,7 +93,7 @@ class ParallelTasks:
self._result_funcs[tid] = result_func or (lambda arg, result: None)
self._args[tid] = arg
precv, psend = multiprocessing.Pipe(False)
context = multiprocessing.get_context('fork')
context: ForkContext = multiprocessing.get_context('fork')
proc = context.Process(target=self._process, args=(psend, task_func, arg))
self._procs[tid] = proc
self._precvsWaiting[tid] = precv

View File

@ -267,7 +267,7 @@ def _restify_py36(cls: Optional[Type], mode: str = 'fully-qualified-except-typin
return reftext + '\\ [%s]' % param_str
else:
return reftext
elif isinstance(cls, typing.GenericMeta):
elif isinstance(cls, typing.GenericMeta): # type: ignore[attr-defined]
if module == 'typing':
reftext = ':py:class:`~typing.%s`' % qualname
else:
@ -505,16 +505,16 @@ def _stringify_py36(annotation: Any, mode: str = 'fully-qualified-except-typing'
return '%s%s[%s]' % (modprefix, qualname, param_str)
else:
return modprefix + qualname
elif isinstance(annotation, typing.GenericMeta):
elif isinstance(annotation, typing.GenericMeta): # type: ignore[attr-defined]
params = None
if annotation.__args__ is None or len(annotation.__args__) <= 2: # type: ignore # NOQA
params = annotation.__args__ # type: ignore
elif annotation.__origin__ == Generator: # type: ignore
params = annotation.__args__ # type: ignore
if annotation.__args__ is None or len(annotation.__args__) <= 2: # NOQA
params = annotation.__args__
elif annotation.__origin__ == Generator:
params = annotation.__args__
else: # typing.Callable
args = ', '.join(stringify(arg, mode) for arg
in annotation.__args__[:-1]) # type: ignore
result = stringify(annotation.__args__[-1]) # type: ignore
in annotation.__args__[:-1])
result = stringify(annotation.__args__[-1])
return '%s%s[[%s], %s]' % (modprefix, qualname, args, result)
if params is not None:
param_str = ', '.join(stringify(p, mode) for p in params)