mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge remote-tracking branch 'origin/4.x' into importlib-metadata
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -22,6 +22,7 @@ Features added
|
||||
this behavior with the ``--respect-module-all`` switch.
|
||||
* #9800: extlinks: Emit warning if a hardcoded link is replaceable
|
||||
by an extlink, suggesting a replacement.
|
||||
* #9961: html: Support nested <kbd> HTML elements in other HTML builders
|
||||
* #9815: html theme: Wrap sidebar components in div to allow customizing their
|
||||
layout via CSS
|
||||
* #9899: py domain: Allows to specify cross-reference specifier (``.`` and
|
||||
@@ -30,6 +31,8 @@ Features added
|
||||
checking in matched documents.
|
||||
* #9793: sphinx-build: Allow to use the parallel build feature in macOS on macOS
|
||||
and Python3.8+
|
||||
* #9993: std domain: Allow to refer an inline target (ex. ``_`target name```)
|
||||
via :rst:role:`ref` role
|
||||
* #9391: texinfo: improve variable in ``samp`` role
|
||||
* #9578: texinfo: Add :confval:`texinfo_cross_references` to disable cross
|
||||
references for readability with standalone readers
|
||||
|
||||
2
setup.py
2
setup.py
@@ -44,7 +44,7 @@ extras_require = {
|
||||
'lint': [
|
||||
'flake8>=3.5.0',
|
||||
'isort',
|
||||
'mypy>=0.920',
|
||||
'mypy>=0.930',
|
||||
'docutils-stubs',
|
||||
"types-typed-ast",
|
||||
"types-requests",
|
||||
|
||||
@@ -36,7 +36,7 @@ class KeyboardTransform(SphinxPostTransform):
|
||||
x
|
||||
"""
|
||||
default_priority = 400
|
||||
builders = ('html',)
|
||||
formats = ('html',)
|
||||
pattern = re.compile(r'(?<=.)(-|\+|\^|\s+)(?=.)')
|
||||
multiwords_keys = (('caps', 'lock'),
|
||||
('page' 'down'),
|
||||
|
||||
@@ -770,10 +770,11 @@ class StandardDomain(Domain):
|
||||
sectname = clean_astext(title)
|
||||
elif node.tagname == 'rubric':
|
||||
sectname = clean_astext(node)
|
||||
elif node.tagname == 'target' and len(node) > 0:
|
||||
# inline target (ex: blah _`blah` blah)
|
||||
sectname = clean_astext(node)
|
||||
elif self.is_enumerable_node(node):
|
||||
sectname = self.get_numfig_title(node)
|
||||
if not sectname:
|
||||
continue
|
||||
else:
|
||||
toctree = next(iter(node.traverse(addnodes.toctree)), None)
|
||||
if toctree and toctree.get('caption'):
|
||||
@@ -781,7 +782,8 @@ class StandardDomain(Domain):
|
||||
else:
|
||||
# anonymous-only labels
|
||||
continue
|
||||
self.labels[name] = docname, labelid, sectname
|
||||
if sectname:
|
||||
self.labels[name] = docname, labelid, sectname
|
||||
|
||||
def add_program_option(self, program: str, name: str, docname: str, labelid: str) -> None:
|
||||
self.progoptions[program, name] = (docname, labelid)
|
||||
|
||||
@@ -621,7 +621,7 @@ class BuildEnvironment:
|
||||
|
||||
def check_consistency(self) -> None:
|
||||
"""Do consistency checks."""
|
||||
included = set().union(*self.included.values()) # type: ignore
|
||||
included = set().union(*self.included.values())
|
||||
for docname in sorted(self.all_docs):
|
||||
if docname not in self.files_to_rebuild:
|
||||
if docname == self.config.root_doc:
|
||||
|
||||
@@ -28,7 +28,7 @@ from docutils.utils import Reporter, unescape
|
||||
from packaging import version
|
||||
|
||||
from sphinx.errors import SphinxError
|
||||
from sphinx.locale import _
|
||||
from sphinx.locale import _, __
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.typing import RoleFunction
|
||||
|
||||
@@ -496,6 +496,9 @@ class SphinxTranslator(nodes.NodeVisitor):
|
||||
else:
|
||||
super().dispatch_departure(node)
|
||||
|
||||
def unknown_visit(self, node: Node) -> None:
|
||||
logger.warning(__('unknown node type: %r'), node, location=node)
|
||||
|
||||
|
||||
# cache a vanilla instance of nodes.document
|
||||
# Used in new_document() function
|
||||
|
||||
@@ -134,7 +134,7 @@ def unwrap_all(obj: Any, *, stop: Callable = None) -> Any:
|
||||
elif ispartial(obj):
|
||||
obj = obj.func
|
||||
elif inspect.isroutine(obj) and hasattr(obj, '__wrapped__'):
|
||||
obj = obj.__wrapped__
|
||||
obj = obj.__wrapped__ # type: ignore
|
||||
elif isclassmethod(obj):
|
||||
obj = obj.__func__
|
||||
elif isstaticmethod(obj):
|
||||
@@ -692,7 +692,7 @@ def signature(subject: Callable, bound_method: bool = False, follow_wrapped: boo
|
||||
#
|
||||
# For example, this helps a function having a default value `inspect._empty`.
|
||||
# refs: https://github.com/sphinx-doc/sphinx/issues/7935
|
||||
return inspect.Signature(parameters, return_annotation=return_annotation, # type: ignore
|
||||
return inspect.Signature(parameters, return_annotation=return_annotation,
|
||||
__validate_parameters__=False)
|
||||
|
||||
|
||||
@@ -820,14 +820,14 @@ def signature_from_ast(node: ast.FunctionDef, code: str = '') -> inspect.Signatu
|
||||
positionals = len(args.args)
|
||||
|
||||
for _ in range(len(defaults), positionals):
|
||||
defaults.insert(0, Parameter.empty)
|
||||
defaults.insert(0, Parameter.empty) # type: ignore
|
||||
|
||||
if hasattr(args, "posonlyargs"):
|
||||
for i, arg in enumerate(args.posonlyargs): # type: ignore
|
||||
if defaults[i] is Parameter.empty:
|
||||
default = Parameter.empty
|
||||
else:
|
||||
default = DefaultValue(ast_unparse(defaults[i], code))
|
||||
default = DefaultValue(ast_unparse(defaults[i], code)) # type: ignore
|
||||
|
||||
annotation = ast_unparse(arg.annotation, code) or Parameter.empty
|
||||
params.append(Parameter(arg.arg, Parameter.POSITIONAL_ONLY,
|
||||
@@ -837,7 +837,7 @@ def signature_from_ast(node: ast.FunctionDef, code: str = '') -> inspect.Signatu
|
||||
if defaults[i + posonlyargs] is Parameter.empty:
|
||||
default = Parameter.empty
|
||||
else:
|
||||
default = DefaultValue(ast_unparse(defaults[i + posonlyargs], code))
|
||||
default = DefaultValue(ast_unparse(defaults[i + posonlyargs], code)) # type: ignore # NOQA
|
||||
|
||||
annotation = ast_unparse(arg.annotation, code) or Parameter.empty
|
||||
params.append(Parameter(arg.arg, Parameter.POSITIONAL_OR_KEYWORD,
|
||||
@@ -849,7 +849,7 @@ def signature_from_ast(node: ast.FunctionDef, code: str = '') -> inspect.Signatu
|
||||
annotation=annotation))
|
||||
|
||||
for i, arg in enumerate(args.kwonlyargs):
|
||||
default = ast_unparse(args.kw_defaults[i], code) or Parameter.empty
|
||||
default = ast_unparse(args.kw_defaults[i], code) or Parameter.empty # type: ignore
|
||||
annotation = ast_unparse(arg.annotation, code) or Parameter.empty
|
||||
params.append(Parameter(arg.arg, Parameter.KEYWORD_ONLY, default=default,
|
||||
annotation=annotation))
|
||||
|
||||
@@ -876,9 +876,6 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
|
||||
if depart:
|
||||
depart(self, node)
|
||||
|
||||
def unknown_visit(self, node: Node) -> None:
|
||||
raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
|
||||
|
||||
@property
|
||||
def permalink_text(self) -> str:
|
||||
warnings.warn('HTMLTranslator.permalink_text is deprecated.',
|
||||
|
||||
@@ -811,9 +811,6 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
||||
if depart:
|
||||
depart(self, node)
|
||||
|
||||
def unknown_visit(self, node: Node) -> None:
|
||||
raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
|
||||
|
||||
@property
|
||||
def permalink_text(self) -> str:
|
||||
warnings.warn('HTMLTranslator.permalink_text is deprecated.',
|
||||
|
||||
@@ -2077,9 +2077,6 @@ class LaTeXTranslator(SphinxTranslator):
|
||||
def depart_math_reference(self, node: Element) -> None:
|
||||
pass
|
||||
|
||||
def unknown_visit(self, node: Node) -> None:
|
||||
raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
|
||||
|
||||
|
||||
# FIXME: Workaround to avoid circular import
|
||||
# refs: https://github.com/sphinx-doc/sphinx/issues/5433
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
from typing import Any, Dict, Iterable, cast
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.nodes import Element, Node, TextElement
|
||||
from docutils.nodes import Element, TextElement
|
||||
from docutils.writers.manpage import Translator as BaseTranslator
|
||||
from docutils.writers.manpage import Writer
|
||||
|
||||
@@ -107,7 +107,7 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator):
|
||||
|
||||
# Overwrite admonition label translations with our own
|
||||
for label, translation in admonitionlabels.items():
|
||||
self.language.labels[label] = self.deunicode(translation) # type: ignore
|
||||
self.language.labels[label] = self.deunicode(translation)
|
||||
|
||||
# overwritten -- added quotes around all .TH arguments
|
||||
def header(self) -> str:
|
||||
@@ -462,6 +462,3 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator):
|
||||
|
||||
def depart_math_block(self, node: Element) -> None:
|
||||
self.depart_centered(node)
|
||||
|
||||
def unknown_visit(self, node: Node) -> None:
|
||||
raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
|
||||
|
||||
@@ -1281,10 +1281,6 @@ class TexinfoTranslator(SphinxTranslator):
|
||||
logger.warning(__("unimplemented node type: %r"), node,
|
||||
location=node)
|
||||
|
||||
def unknown_visit(self, node: Node) -> None:
|
||||
logger.warning(__("unknown node type: %r"), node,
|
||||
location=node)
|
||||
|
||||
def unknown_departure(self, node: Node) -> None:
|
||||
pass
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ from typing import (TYPE_CHECKING, Any, Dict, Generator, Iterable, List, Optiona
|
||||
Union, cast)
|
||||
|
||||
from docutils import nodes, writers
|
||||
from docutils.nodes import Element, Node, Text
|
||||
from docutils.nodes import Element, Text
|
||||
from docutils.utils import column_width
|
||||
|
||||
from sphinx import addnodes
|
||||
@@ -1189,6 +1189,3 @@ class TextTranslator(SphinxTranslator):
|
||||
|
||||
def depart_math_block(self, node: Element) -> None:
|
||||
self.end_state()
|
||||
|
||||
def unknown_visit(self, node: Node) -> None:
|
||||
raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
|
||||
|
||||
@@ -452,3 +452,12 @@ def test_labeled_rubric(app):
|
||||
domain = app.env.get_domain("std")
|
||||
assert 'label' in domain.labels
|
||||
assert domain.labels['label'] == ('index', 'label', 'blah blah blah')
|
||||
|
||||
|
||||
def test_inline_target(app):
|
||||
text = "blah _`inline target` blah\n"
|
||||
restructuredtext.parse(app, text)
|
||||
|
||||
domain = app.env.get_domain("std")
|
||||
assert 'inline target' in domain.labels
|
||||
assert domain.labels['inline target'] == ('index', 'inline-target', 'inline target')
|
||||
|
||||
Reference in New Issue
Block a user