mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix COM812
This commit is contained in:
@@ -31,7 +31,7 @@ class IntEnumDocumenter(ClassDocumenter):
|
||||
|
||||
def add_content(self,
|
||||
more_content: StringList | None,
|
||||
no_docstring: bool = False
|
||||
no_docstring: bool = False,
|
||||
) -> None:
|
||||
|
||||
super().add_content(more_content, no_docstring)
|
||||
|
||||
@@ -102,14 +102,14 @@ class RecipeDomain(Domain):
|
||||
name = 'recipe'
|
||||
label = 'Recipe Sample'
|
||||
roles = {
|
||||
'ref': XRefRole()
|
||||
'ref': XRefRole(),
|
||||
}
|
||||
directives = {
|
||||
'recipe': RecipeDirective,
|
||||
}
|
||||
indices = {
|
||||
RecipeIndex,
|
||||
IngredientIndex
|
||||
IngredientIndex,
|
||||
}
|
||||
initial_data = {
|
||||
'recipes': [], # object list
|
||||
|
||||
@@ -239,7 +239,7 @@ class Sphinx:
|
||||
raise ConfigError(
|
||||
__("'setup' as currently defined in conf.py isn't a Python callable. "
|
||||
"Please modify its definition to make it a callable function. "
|
||||
"This is needed for conf.py to behave as a Sphinx extension.")
|
||||
"This is needed for conf.py to behave as a Sphinx extension."),
|
||||
)
|
||||
|
||||
# now that we know all config values, collect them from conf.py
|
||||
@@ -380,7 +380,7 @@ class Sphinx:
|
||||
logger.info('')
|
||||
logger.info(self.builder.epilog % {
|
||||
'outdir': relpath(self.outdir),
|
||||
'project': self.config.project
|
||||
'project': self.config.project,
|
||||
})
|
||||
|
||||
self.builder.cleanup()
|
||||
@@ -778,7 +778,7 @@ class Sphinx:
|
||||
"""
|
||||
self.registry.add_role_to_domain(domain, name, role, override=override)
|
||||
|
||||
def add_index_to_domain(self, domain: str, index: type[Index], override: bool = False
|
||||
def add_index_to_domain(self, domain: str, index: type[Index], override: bool = False,
|
||||
) -> None:
|
||||
"""Register a custom index for a domain.
|
||||
|
||||
@@ -799,7 +799,7 @@ class Sphinx:
|
||||
def add_object_type(self, directivename: str, rolename: str, indextemplate: str = '',
|
||||
parse_node: Callable | None = None,
|
||||
ref_nodeclass: type[TextElement] | None = None,
|
||||
objname: str = '', doc_field_types: list = [], override: bool = False
|
||||
objname: str = '', doc_field_types: list = [], override: bool = False,
|
||||
) -> None:
|
||||
"""Register a new object type.
|
||||
|
||||
@@ -1142,7 +1142,7 @@ class Sphinx:
|
||||
self.registry.add_documenter(cls.objtype, cls)
|
||||
self.add_directive('auto' + cls.objtype, AutodocDirective, override=override)
|
||||
|
||||
def add_autodoc_attrgetter(self, typ: type, getter: Callable[[Any, str, Any], Any]
|
||||
def add_autodoc_attrgetter(self, typ: type, getter: Callable[[Any, str, Any], Any],
|
||||
) -> None:
|
||||
"""Register a new ``getattr``-like function for the autodoc extension.
|
||||
|
||||
@@ -1312,7 +1312,7 @@ class TemplateBridge:
|
||||
self,
|
||||
builder: Builder,
|
||||
theme: Theme | None = None,
|
||||
dirs: list[str] | None = None
|
||||
dirs: list[str] | None = None,
|
||||
) -> None:
|
||||
"""Called by the builder to initialize the template system.
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ class Builder:
|
||||
len(to_build))
|
||||
|
||||
def build(
|
||||
self, docnames: Iterable[str], summary: str | None = None, method: str = 'update'
|
||||
self, docnames: Iterable[str], summary: str | None = None, method: str = 'update',
|
||||
) -> None:
|
||||
"""Main build method.
|
||||
|
||||
@@ -548,7 +548,7 @@ class Builder:
|
||||
self,
|
||||
build_docnames: Iterable[str],
|
||||
updated_docnames: Sequence[str],
|
||||
method: str = 'update'
|
||||
method: str = 'update',
|
||||
) -> None:
|
||||
if build_docnames is None or build_docnames == ['__all__']:
|
||||
# build_all
|
||||
|
||||
@@ -53,7 +53,7 @@ CSS_LINK_TARGET_CLASS = 'link-target'
|
||||
# XXX These strings should be localized according to epub_language
|
||||
GUIDE_TITLES = {
|
||||
'toc': 'Table of Contents',
|
||||
'cover': 'Cover'
|
||||
'cover': 'Cover',
|
||||
}
|
||||
|
||||
MEDIA_TYPES = {
|
||||
@@ -183,7 +183,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
||||
return id
|
||||
|
||||
def get_refnodes(
|
||||
self, doctree: Node, result: list[dict[str, Any]]
|
||||
self, doctree: Node, result: list[dict[str, Any]],
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Collect section titles, their depth in the toc and the refuri."""
|
||||
# XXX: is there a better way than checking the attribute
|
||||
@@ -198,7 +198,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
||||
result.append({
|
||||
'level': level,
|
||||
'refuri': html.escape(refuri),
|
||||
'text': ssp(html.escape(doctree.astext()))
|
||||
'text': ssp(html.escape(doctree.astext())),
|
||||
})
|
||||
break
|
||||
elif isinstance(doctree, nodes.Element):
|
||||
@@ -241,19 +241,19 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
||||
'level': 1,
|
||||
'refuri': html.escape(self.config.root_doc + self.out_suffix),
|
||||
'text': ssp(html.escape(
|
||||
self.env.titles[self.config.root_doc].astext()))
|
||||
self.env.titles[self.config.root_doc].astext())),
|
||||
})
|
||||
for file, text in reversed(self.config.epub_pre_files):
|
||||
refnodes.insert(0, {
|
||||
'level': 1,
|
||||
'refuri': html.escape(file),
|
||||
'text': ssp(html.escape(text))
|
||||
'text': ssp(html.escape(text)),
|
||||
})
|
||||
for file, text in self.config.epub_post_files:
|
||||
refnodes.append({
|
||||
'level': 1,
|
||||
'refuri': html.escape(file),
|
||||
'text': ssp(html.escape(text))
|
||||
'text': ssp(html.escape(text)),
|
||||
})
|
||||
|
||||
def fix_fragment(self, prefix: str, fragment: str) -> str:
|
||||
|
||||
@@ -128,7 +128,7 @@ class ChangesBuilder(Builder):
|
||||
text = ''.join(hl(i + 1, line) for (i, line) in enumerate(lines))
|
||||
ctx = {
|
||||
'filename': self.env.doc2path(docname, False),
|
||||
'text': text
|
||||
'text': text,
|
||||
}
|
||||
f.write(self.templates.render('changes/rstsource.html', ctx))
|
||||
themectx = {'theme_' + key: val for (key, val) in
|
||||
|
||||
@@ -167,7 +167,7 @@ class Epub3Builder(_epub_base.EpubBuilder):
|
||||
return {
|
||||
'lang': html.escape(self.config.epub_language),
|
||||
'toc_locale': html.escape(self.guide_titles['toc']),
|
||||
'navlist': navlist
|
||||
'navlist': navlist,
|
||||
}
|
||||
|
||||
def build_navigation_doc(self) -> None:
|
||||
|
||||
@@ -82,7 +82,7 @@ class MsgOrigin:
|
||||
|
||||
class GettextRenderer(SphinxRenderer):
|
||||
def __init__(
|
||||
self, template_path: str | None = None, outdir: str | None = None
|
||||
self, template_path: str | None = None, outdir: str | None = None,
|
||||
) -> None:
|
||||
self.outdir = outdir
|
||||
if template_path is None:
|
||||
@@ -257,7 +257,7 @@ class MessageCatalogBuilder(I18nBuilder):
|
||||
raise ThemeError(f'{template}: {exc!r}') from exc
|
||||
|
||||
def build(
|
||||
self, docnames: Iterable[str], summary: str | None = None, method: str = 'update'
|
||||
self, docnames: Iterable[str], summary: str | None = None, method: str = 'update',
|
||||
) -> None:
|
||||
self._extract_from_template()
|
||||
super().build(docnames, summary, method)
|
||||
|
||||
@@ -63,7 +63,7 @@ DOMAIN_INDEX_TYPE = Tuple[
|
||||
# list of (heading string, list of index entries) pairs.
|
||||
List[Tuple[str, List[IndexEntry]]],
|
||||
# whether sub-entries should start collapsed
|
||||
bool
|
||||
bool,
|
||||
]
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class Stylesheet(str):
|
||||
filename: str = None
|
||||
priority: int = None
|
||||
|
||||
def __new__(cls, filename: str, *args: str, priority: int = 500, **attributes: Any
|
||||
def __new__(cls, filename: str, *args: str, priority: int = 500, **attributes: Any,
|
||||
) -> Stylesheet:
|
||||
self = str.__new__(cls, filename)
|
||||
self.filename = filename
|
||||
@@ -160,7 +160,7 @@ class BuildInfo:
|
||||
raise ValueError(__('build info file is broken: %r') % exc) from exc
|
||||
|
||||
def __init__(
|
||||
self, config: Config = None, tags: Tags = None, config_categories: list[str] = []
|
||||
self, config: Config = None, tags: Tags = None, config_categories: list[str] = [],
|
||||
) -> None:
|
||||
self.config_hash = ''
|
||||
self.tags_hash = ''
|
||||
@@ -586,7 +586,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
try:
|
||||
next = {
|
||||
'link': self.get_relative_uri(docname, related[2]),
|
||||
'title': self.render_partial(titles[related[2]])['title']
|
||||
'title': self.render_partial(titles[related[2]])['title'],
|
||||
}
|
||||
rellinks.append((related[2], next['title'], 'N', _('next')))
|
||||
except KeyError:
|
||||
@@ -595,7 +595,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
try:
|
||||
prev = {
|
||||
'link': self.get_relative_uri(docname, related[1]),
|
||||
'title': self.render_partial(titles[related[1]])['title']
|
||||
'title': self.render_partial(titles[related[1]])['title'],
|
||||
}
|
||||
rellinks.append((related[1], prev['title'], 'P', _('previous')))
|
||||
except KeyError:
|
||||
@@ -1041,7 +1041,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
ctx['pageurl'] = None
|
||||
|
||||
def pathto(
|
||||
otheruri: str, resource: bool = False, baseuri: str = default_baseuri
|
||||
otheruri: str, resource: bool = False, baseuri: str = default_baseuri,
|
||||
) -> str:
|
||||
if resource and '://' in otheruri:
|
||||
# allow non-local resources given by scheme
|
||||
|
||||
@@ -325,7 +325,7 @@ class LaTeXBuilder(Builder):
|
||||
self.context['wrapperclass'] = theme.wrapperclass
|
||||
|
||||
def assemble_doctree(
|
||||
self, indexfile: str, toctree_only: bool, appendices: list[str]
|
||||
self, indexfile: str, toctree_only: bool, appendices: list[str],
|
||||
) -> nodes.document:
|
||||
self.docnames = set([indexfile] + appendices)
|
||||
logger.info(darkgreen(indexfile) + " ", nonl=True)
|
||||
@@ -437,7 +437,7 @@ class LaTeXBuilder(Builder):
|
||||
'addtocaptions': r'\@iden',
|
||||
'figurename': formats.get('figure', '').split('%s', 1),
|
||||
'tablename': formats.get('table', '').split('%s', 1),
|
||||
'literalblockname': formats.get('code-block', '').split('%s', 1)
|
||||
'literalblockname': formats.get('code-block', '').split('%s', 1),
|
||||
}
|
||||
|
||||
if self.context['babel'] or self.context['polyglossia']:
|
||||
|
||||
@@ -114,7 +114,7 @@ class ShowUrlsTransform(SphinxPostTransform):
|
||||
raise ValueError(f'Failed to get a docname for source {source!r}!')
|
||||
|
||||
def create_footnote(
|
||||
self, uri: str, docname: str
|
||||
self, uri: str, docname: str,
|
||||
) -> tuple[nodes.footnote, nodes.footnote_reference]:
|
||||
reference = nodes.reference('', nodes.Text(uri), refuri=uri, nolinkurl=True)
|
||||
footnote = nodes.footnote(uri, auto=1, docname=docname)
|
||||
|
||||
@@ -126,7 +126,7 @@ class TexinfoBuilder(Builder):
|
||||
self.copy_image_files(targetname[:-5])
|
||||
|
||||
def assemble_doctree(
|
||||
self, indexfile: str, toctree_only: bool, appendices: list[str]
|
||||
self, indexfile: str, toctree_only: bool, appendices: list[str],
|
||||
) -> nodes.document:
|
||||
self.docnames = set([indexfile] + appendices)
|
||||
logger.info(darkgreen(indexfile) + " ", nonl=True)
|
||||
@@ -198,7 +198,7 @@ class TexinfoBuilder(Builder):
|
||||
|
||||
|
||||
def default_texinfo_documents(
|
||||
config: Config
|
||||
config: Config,
|
||||
) -> list[tuple[str, str, str, str, str, str, str]]:
|
||||
""" Better default texinfo_documents settings. """
|
||||
filename = make_filename_from_project(config.project)
|
||||
|
||||
@@ -28,7 +28,7 @@ from sphinx.util.osutil import abspath, ensuredir
|
||||
|
||||
|
||||
def handle_exception(
|
||||
app: Sphinx | None, args: Any, exception: BaseException, stderr: TextIO = sys.stderr
|
||||
app: Sphinx | None, args: Any, exception: BaseException, stderr: TextIO = sys.stderr,
|
||||
) -> None:
|
||||
if isinstance(exception, bdb.BdbQuit):
|
||||
return
|
||||
|
||||
@@ -133,7 +133,7 @@ def ok(x: str) -> str:
|
||||
|
||||
|
||||
def do_prompt(
|
||||
text: str, default: str | None = None, validator: Callable[[str], Any] = nonempty
|
||||
text: str, default: str | None = None, validator: Callable[[str], Any] = nonempty,
|
||||
) -> str | bool:
|
||||
while True:
|
||||
if default is not None:
|
||||
@@ -269,7 +269,7 @@ def ask_user(d: dict[str, Any]) -> None:
|
||||
'translate text that it generates into that language.\n'
|
||||
'\n'
|
||||
'For a list of supported codes, see\n'
|
||||
'https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language.'
|
||||
'https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language.',
|
||||
))
|
||||
d['language'] = do_prompt(__('Project language'), 'en')
|
||||
if d['language'] == 'en':
|
||||
@@ -325,7 +325,7 @@ def ask_user(d: dict[str, Any]) -> None:
|
||||
|
||||
|
||||
def generate(
|
||||
d: dict, overwrite: bool = True, silent: bool = False, templatedir: str | None = None
|
||||
d: dict, overwrite: bool = True, silent: bool = False, templatedir: str | None = None,
|
||||
) -> None:
|
||||
"""Generate project based on values in *d*."""
|
||||
template = QuickstartRenderer(templatedir or '')
|
||||
@@ -462,7 +462,7 @@ def get_parser() -> argparse.ArgumentParser:
|
||||
"\n"
|
||||
"sphinx-quickstart is an interactive tool that asks some questions about your\n"
|
||||
"project and then generates a complete documentation directory and sample\n"
|
||||
"Makefile to be used with sphinx-build.\n"
|
||||
"Makefile to be used with sphinx-build.\n",
|
||||
)
|
||||
parser = argparse.ArgumentParser(
|
||||
usage='%(prog)s [OPTIONS] <PROJECT_DIR>',
|
||||
|
||||
@@ -163,7 +163,7 @@ class Config:
|
||||
|
||||
@classmethod
|
||||
def read(
|
||||
cls, confdir: str, overrides: dict | None = None, tags: Tags | None = None
|
||||
cls, confdir: str, overrides: dict | None = None, tags: Tags | None = None,
|
||||
) -> Config:
|
||||
"""Create a Config object from configuration file."""
|
||||
filename = path.join(confdir, CONFIG_FILENAME)
|
||||
|
||||
@@ -21,7 +21,7 @@ def _deprecation_warning(
|
||||
attribute: str,
|
||||
canonical_name: str,
|
||||
*,
|
||||
remove: tuple[int, int]
|
||||
remove: tuple[int, int],
|
||||
) -> None:
|
||||
"""Helper function for module-level deprecations using __getattr__
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class Highlight(SphinxDirective):
|
||||
|
||||
|
||||
def dedent_lines(
|
||||
lines: list[str], dedent: int | None, location: tuple[str, int] | None = None
|
||||
lines: list[str], dedent: int | None, location: tuple[str, int] | None = None,
|
||||
) -> list[str]:
|
||||
if dedent is None:
|
||||
return textwrap.dedent(''.join(lines)).splitlines(True)
|
||||
@@ -70,7 +70,7 @@ def dedent_lines(
|
||||
|
||||
|
||||
def container_wrapper(
|
||||
directive: SphinxDirective, literal_node: Node, caption: str
|
||||
directive: SphinxDirective, literal_node: Node, caption: str,
|
||||
) -> nodes.container:
|
||||
container_node = nodes.container('', literal_block=True,
|
||||
classes=['literal-block-wrapper'])
|
||||
@@ -207,7 +207,7 @@ class LiteralIncludeReader:
|
||||
(option1, option2))
|
||||
|
||||
def read_file(
|
||||
self, filename: str, location: tuple[str, int] | None = None
|
||||
self, filename: str, location: tuple[str, int] | None = None,
|
||||
) -> list[str]:
|
||||
try:
|
||||
with open(filename, encoding=self.encoding, errors='strict') as f:
|
||||
@@ -249,7 +249,7 @@ class LiteralIncludeReader:
|
||||
return list(diff)
|
||||
|
||||
def pyobject_filter(
|
||||
self, lines: list[str], location: tuple[str, int] | None = None
|
||||
self, lines: list[str], location: tuple[str, int] | None = None,
|
||||
) -> list[str]:
|
||||
pyobject = self.options.get('pyobject')
|
||||
if pyobject:
|
||||
@@ -269,7 +269,7 @@ class LiteralIncludeReader:
|
||||
return lines
|
||||
|
||||
def lines_filter(
|
||||
self, lines: list[str], location: tuple[str, int] | None = None
|
||||
self, lines: list[str], location: tuple[str, int] | None = None,
|
||||
) -> list[str]:
|
||||
linespec = self.options.get('lines')
|
||||
if linespec:
|
||||
@@ -295,7 +295,7 @@ class LiteralIncludeReader:
|
||||
return lines
|
||||
|
||||
def start_filter(
|
||||
self, lines: list[str], location: tuple[str, int] | None = None
|
||||
self, lines: list[str], location: tuple[str, int] | None = None,
|
||||
) -> list[str]:
|
||||
if 'start-at' in self.options:
|
||||
start = self.options.get('start-at')
|
||||
@@ -328,7 +328,7 @@ class LiteralIncludeReader:
|
||||
return lines
|
||||
|
||||
def end_filter(
|
||||
self, lines: list[str], location: tuple[str, int] | None = None
|
||||
self, lines: list[str], location: tuple[str, int] | None = None,
|
||||
) -> list[str]:
|
||||
if 'end-at' in self.options:
|
||||
end = self.options.get('end-at')
|
||||
@@ -357,7 +357,7 @@ class LiteralIncludeReader:
|
||||
return lines
|
||||
|
||||
def prepend_filter(
|
||||
self, lines: list[str], location: tuple[str, int] | None = None
|
||||
self, lines: list[str], location: tuple[str, int] | None = None,
|
||||
) -> list[str]:
|
||||
prepend = self.options.get('prepend')
|
||||
if prepend:
|
||||
@@ -366,7 +366,7 @@ class LiteralIncludeReader:
|
||||
return lines
|
||||
|
||||
def append_filter(
|
||||
self, lines: list[str], location: tuple[str, int] | None = None
|
||||
self, lines: list[str], location: tuple[str, int] | None = None,
|
||||
) -> list[str]:
|
||||
append = self.options.get('append')
|
||||
if append:
|
||||
@@ -375,7 +375,7 @@ class LiteralIncludeReader:
|
||||
return lines
|
||||
|
||||
def dedent_filter(
|
||||
self, lines: list[str], location: tuple[str, int] | None = None
|
||||
self, lines: list[str], location: tuple[str, int] | None = None,
|
||||
) -> list[str]:
|
||||
if 'dedent' in self.options:
|
||||
return dedent_lines(lines, self.options.get('dedent'), location=location)
|
||||
|
||||
@@ -97,7 +97,7 @@ class Index(ABC):
|
||||
self.domain = domain
|
||||
|
||||
@abstractmethod
|
||||
def generate(self, docnames: Iterable[str] | None = None
|
||||
def generate(self, docnames: Iterable[str] | None = None,
|
||||
) -> tuple[list[tuple[str, list[IndexEntry]]], bool]:
|
||||
"""Get entries for the index.
|
||||
|
||||
@@ -262,7 +262,7 @@ class Domain:
|
||||
fullname = f'{self.name}:{name}'
|
||||
|
||||
def role_adapter(typ: str, rawtext: str, text: str, lineno: int,
|
||||
inliner: Inliner, options: dict = {}, content: list[str] = []
|
||||
inliner: Inliner, options: dict = {}, content: list[str] = [],
|
||||
) -> tuple[list[Node], list[system_message]]:
|
||||
return self.roles[name](fullname, rawtext, text, lineno,
|
||||
inliner, options, content)
|
||||
@@ -317,7 +317,7 @@ class Domain:
|
||||
pass
|
||||
|
||||
def resolve_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
typ: str, target: str, node: pending_xref, contnode: Element
|
||||
typ: str, target: str, node: pending_xref, contnode: Element,
|
||||
) -> Element | None:
|
||||
"""Resolve the pending_xref *node* with the given *typ* and *target*.
|
||||
|
||||
@@ -335,7 +335,7 @@ class Domain:
|
||||
pass
|
||||
|
||||
def resolve_any_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
target: str, node: pending_xref, contnode: Element
|
||||
target: str, node: pending_xref, contnode: Element,
|
||||
) -> list[tuple[str, Element]]:
|
||||
"""Resolve the pending_xref *node* with the given *target*.
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ _expression_bin_ops = [
|
||||
['<<', '>>'],
|
||||
['+', '-'],
|
||||
['*', '/', '%'],
|
||||
['.*', '->*']
|
||||
['.*', '->*'],
|
||||
]
|
||||
_expression_unary_ops = ["++", "--", "*", "&", "+", "-", "!", "not", "~", "compl"]
|
||||
_expression_assignment_ops = ["=", "*=", "/=", "%=", "+=", "-=",
|
||||
@@ -1766,7 +1766,7 @@ class Symbol:
|
||||
ancestorLookupType: str | None,
|
||||
matchSelf: bool,
|
||||
recurseInAnon: bool,
|
||||
searchInSiblings: bool
|
||||
searchInSiblings: bool,
|
||||
) -> SymbolLookupResult | None:
|
||||
# TODO: further simplification from C++ to C
|
||||
# ancestorLookupType: if not None, specifies the target type of the lookup
|
||||
@@ -2063,7 +2063,7 @@ class Symbol:
|
||||
return res
|
||||
|
||||
def find_identifier(self, ident: ASTIdentifier,
|
||||
matchSelf: bool, recurseInAnon: bool, searchInSiblings: bool
|
||||
matchSelf: bool, recurseInAnon: bool, searchInSiblings: bool,
|
||||
) -> Symbol | None:
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_indent += 1
|
||||
@@ -2275,7 +2275,7 @@ class DefinitionParser(BaseParser):
|
||||
return ASTIdExpression(nn)
|
||||
return None
|
||||
|
||||
def _parse_initializer_list(self, name: str, open: str, close: str
|
||||
def _parse_initializer_list(self, name: str, open: str, close: str,
|
||||
) -> tuple[list[ASTExpression], bool]:
|
||||
# Parse open and close with the actual initializer-list in between
|
||||
# -> initializer-clause '...'[opt]
|
||||
@@ -2683,7 +2683,7 @@ class DefinitionParser(BaseParser):
|
||||
return ASTParameters(args, attrs)
|
||||
|
||||
def _parse_decl_specs_simple(
|
||||
self, outer: str | None, typed: bool
|
||||
self, outer: str | None, typed: bool,
|
||||
) -> ASTDeclSpecsSimple:
|
||||
"""Just parse the simple ones."""
|
||||
storage = None
|
||||
@@ -2757,7 +2757,7 @@ class DefinitionParser(BaseParser):
|
||||
return ASTDeclSpecs(outer, leftSpecs, rightSpecs, trailing)
|
||||
|
||||
def _parse_declarator_name_suffix(
|
||||
self, named: bool | str, paramMode: str, typed: bool
|
||||
self, named: bool | str, paramMode: str, typed: bool,
|
||||
) -> ASTDeclarator:
|
||||
assert named in (True, False, 'single')
|
||||
# now we should parse the name, and then suffixes
|
||||
@@ -2918,7 +2918,7 @@ class DefinitionParser(BaseParser):
|
||||
header = "Error in declarator or parameters"
|
||||
raise self._make_multi_error(prevErrors, header) from e
|
||||
|
||||
def _parse_initializer(self, outer: str | None = None, allowFallback: bool = True
|
||||
def _parse_initializer(self, outer: str | None = None, allowFallback: bool = True,
|
||||
) -> ASTInitializer | None:
|
||||
self.skip_ws()
|
||||
if outer == 'member' and False: # NoQA: SIM223 # TODO
|
||||
@@ -3740,7 +3740,7 @@ class CDomain(Domain):
|
||||
'namespace-push': CNamespacePushObject,
|
||||
'namespace-pop': CNamespacePopObject,
|
||||
# other
|
||||
'alias': CAliasObject
|
||||
'alias': CAliasObject,
|
||||
}
|
||||
roles = {
|
||||
'member': CXRefRole(),
|
||||
@@ -3754,7 +3754,7 @@ class CDomain(Domain):
|
||||
'enumerator': CXRefRole(),
|
||||
'type': CXRefRole(),
|
||||
'expr': CExprRole(asCode=True),
|
||||
'texpr': CExprRole(asCode=False)
|
||||
'texpr': CExprRole(asCode=False),
|
||||
}
|
||||
initial_data: dict[str, Symbol | dict[str, tuple[str, str, str]]] = {
|
||||
'root_symbol': Symbol(None, None, None, None, None),
|
||||
@@ -3841,7 +3841,7 @@ class CDomain(Domain):
|
||||
assert docname
|
||||
|
||||
return make_refnode(builder, fromdocname, docname,
|
||||
declaration.get_newest_id(), contnode, displayName
|
||||
declaration.get_newest_id(), contnode, displayName,
|
||||
), declaration.objectType
|
||||
|
||||
def resolve_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
@@ -3851,7 +3851,7 @@ class CDomain(Domain):
|
||||
target, node, contnode)[0]
|
||||
|
||||
def resolve_any_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
target: str, node: pending_xref, contnode: Element
|
||||
target: str, node: pending_xref, contnode: Element,
|
||||
) -> list[tuple[str, Element]]:
|
||||
with logging.suppress_logging():
|
||||
retnode, objtype = self._resolve_xref_inner(env, fromdocname, builder,
|
||||
|
||||
@@ -138,7 +138,7 @@ class ChangeSetDomain(Domain):
|
||||
changes.append(changeset)
|
||||
|
||||
def process_doc(
|
||||
self, env: BuildEnvironment, docname: str, document: nodes.document
|
||||
self, env: BuildEnvironment, docname: str, document: nodes.document,
|
||||
) -> None:
|
||||
pass # nothing to do here. All changesets are registered on calling directive.
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class CitationDomain(Domain):
|
||||
type='ref', subtype='citation', location=(docname, lineno))
|
||||
|
||||
def resolve_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
typ: str, target: str, node: pending_xref, contnode: Element
|
||||
typ: str, target: str, node: pending_xref, contnode: Element,
|
||||
) -> Element | None:
|
||||
docname, labelid, lineno = self.citations.get(target, ('', '', 0))
|
||||
if not docname:
|
||||
@@ -91,7 +91,7 @@ class CitationDomain(Domain):
|
||||
labelid, contnode)
|
||||
|
||||
def resolve_any_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
target: str, node: pending_xref, contnode: Element
|
||||
target: str, node: pending_xref, contnode: Element,
|
||||
) -> list[tuple[str, Element]]:
|
||||
refnode = self.resolve_xref(env, fromdocname, builder, 'ref', target, node, contnode)
|
||||
if refnode is None:
|
||||
|
||||
@@ -340,7 +340,7 @@ _keywords = [
|
||||
'static_assert', 'static_cast', 'struct', 'switch', 'template', 'this',
|
||||
'thread_local', 'throw', 'true', 'try', 'typedef', 'typeid', 'typename',
|
||||
'union', 'unsigned', 'using', 'virtual', 'void', 'volatile', 'wchar_t',
|
||||
'while', 'xor', 'xor_eq'
|
||||
'while', 'xor', 'xor_eq',
|
||||
]
|
||||
|
||||
|
||||
@@ -377,7 +377,7 @@ _id_fundamental_v1 = {
|
||||
'long': 'l',
|
||||
'signed long': 'l',
|
||||
'unsigned long': 'L',
|
||||
'bool': 'b'
|
||||
'bool': 'b',
|
||||
}
|
||||
_id_shorthands_v1 = {
|
||||
'std::string': 'ss',
|
||||
@@ -385,7 +385,7 @@ _id_shorthands_v1 = {
|
||||
'std::istream': 'is',
|
||||
'std::iostream': 'ios',
|
||||
'std::vector': 'v',
|
||||
'std::map': 'm'
|
||||
'std::map': 'm',
|
||||
}
|
||||
_id_operator_v1 = {
|
||||
'new': 'new-operator',
|
||||
@@ -434,7 +434,7 @@ _id_operator_v1 = {
|
||||
'->*': 'pointer-by-pointer-operator',
|
||||
'->': 'pointer-operator',
|
||||
'()': 'call-operator',
|
||||
'[]': 'subscript-operator'
|
||||
'[]': 'subscript-operator',
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
@@ -492,7 +492,7 @@ _id_fundamental_v2 = {
|
||||
'_Imaginary long double': 'e',
|
||||
'auto': 'Da',
|
||||
'decltype(auto)': 'Dc',
|
||||
'std::nullptr_t': 'Dn'
|
||||
'std::nullptr_t': 'Dn',
|
||||
}
|
||||
_id_operator_v2 = {
|
||||
'new': 'nw',
|
||||
@@ -555,11 +555,11 @@ _id_operator_unary_v2 = {
|
||||
'+': 'ps',
|
||||
'-': 'ng',
|
||||
'!': 'nt', 'not': 'nt',
|
||||
'~': 'co', 'compl': 'co'
|
||||
'~': 'co', 'compl': 'co',
|
||||
}
|
||||
_id_char_from_prefix: dict[str | None, str] = {
|
||||
None: 'c', 'u8': 'c',
|
||||
'u': 'Ds', 'U': 'Di', 'L': 'w'
|
||||
'u': 'Ds', 'U': 'Di', 'L': 'w',
|
||||
}
|
||||
# these are ordered by preceedence
|
||||
_expression_bin_ops = [
|
||||
@@ -573,7 +573,7 @@ _expression_bin_ops = [
|
||||
['<<', '>>'],
|
||||
['+', '-'],
|
||||
['*', '/', '%'],
|
||||
['.*', '->*']
|
||||
['.*', '->*'],
|
||||
]
|
||||
_expression_unary_ops = ["++", "--", "*", "&", "+", "-", "!", "not", "~", "compl"]
|
||||
_expression_assignment_ops = ["=", "*=", "/=", "%=", "+=", "-=",
|
||||
@@ -582,7 +582,7 @@ _id_explicit_cast = {
|
||||
'dynamic_cast': 'dc',
|
||||
'static_cast': 'sc',
|
||||
'const_cast': 'cc',
|
||||
'reinterpret_cast': 'rc'
|
||||
'reinterpret_cast': 'rc',
|
||||
}
|
||||
|
||||
|
||||
@@ -3661,7 +3661,7 @@ class ASTTemplateParamTemplateType(ASTTemplateParam):
|
||||
return self.data.get_identifier()
|
||||
|
||||
def get_id(
|
||||
self, version: int, objectType: str | None = None, symbol: Symbol | None = None
|
||||
self, version: int, objectType: str | None = None, symbol: Symbol | None = None,
|
||||
) -> str:
|
||||
assert version >= 2
|
||||
# this is not part of the normal name mangling in C++
|
||||
@@ -4405,7 +4405,7 @@ class Symbol:
|
||||
def _find_first_named_symbol(self, identOrOp: ASTIdentifier | ASTOperator,
|
||||
templateParams: Any, templateArgs: ASTTemplateArgs,
|
||||
templateShorthand: bool, matchSelf: bool,
|
||||
recurseInAnon: bool, correctPrimaryTemplateArgs: bool
|
||||
recurseInAnon: bool, correctPrimaryTemplateArgs: bool,
|
||||
) -> Symbol:
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_print("_find_first_named_symbol ->")
|
||||
@@ -4508,12 +4508,12 @@ class Symbol:
|
||||
nestedName: ASTNestedName,
|
||||
templateDecls: list[Any],
|
||||
onMissingQualifiedSymbol: Callable[
|
||||
[Symbol, ASTIdentifier | ASTOperator, Any, ASTTemplateArgs], Symbol
|
||||
[Symbol, ASTIdentifier | ASTOperator, Any, ASTTemplateArgs], Symbol,
|
||||
],
|
||||
strictTemplateParamArgLists: bool, ancestorLookupType: str,
|
||||
templateShorthand: bool, matchSelf: bool,
|
||||
recurseInAnon: bool, correctPrimaryTemplateArgs: bool,
|
||||
searchInSiblings: bool
|
||||
searchInSiblings: bool,
|
||||
) -> SymbolLookupResult:
|
||||
# ancestorLookupType: if not None, specifies the target type of the lookup
|
||||
if Symbol.debug_lookup:
|
||||
@@ -4654,7 +4654,7 @@ class Symbol:
|
||||
|
||||
def onMissingQualifiedSymbol(parentSymbol: Symbol,
|
||||
identOrOp: ASTIdentifier | ASTOperator,
|
||||
templateParams: Any, templateArgs: ASTTemplateArgs
|
||||
templateParams: Any, templateArgs: ASTTemplateArgs,
|
||||
) -> Symbol:
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_indent += 1
|
||||
@@ -4963,7 +4963,7 @@ class Symbol:
|
||||
return res
|
||||
|
||||
def find_identifier(self, identOrOp: ASTIdentifier | ASTOperator,
|
||||
matchSelf: bool, recurseInAnon: bool, searchInSiblings: bool
|
||||
matchSelf: bool, recurseInAnon: bool, searchInSiblings: bool,
|
||||
) -> Symbol:
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_indent += 1
|
||||
@@ -5334,7 +5334,7 @@ class DefinitionParser(BaseParser):
|
||||
except DefinitionError as eExpr:
|
||||
raise self._make_multi_error([
|
||||
(eFold, "If fold expression"),
|
||||
(eExpr, "If parenthesized expression")
|
||||
(eExpr, "If parenthesized expression"),
|
||||
], "Error in fold expression or parenthesized expression.") from eExpr
|
||||
return ASTParenExpr(res)
|
||||
# now it definitely is a fold expression
|
||||
@@ -5374,7 +5374,7 @@ class DefinitionParser(BaseParser):
|
||||
return ASTIdExpression(nn)
|
||||
return None
|
||||
|
||||
def _parse_initializer_list(self, name: str, open: str, close: str
|
||||
def _parse_initializer_list(self, name: str, open: str, close: str,
|
||||
) -> tuple[list[ASTExpression | ASTBracedInitList],
|
||||
bool]:
|
||||
# Parse open and close with the actual initializer-list in between
|
||||
@@ -5435,7 +5435,7 @@ class DefinitionParser(BaseParser):
|
||||
return ASTBracedInitList(exprs, trailingComma)
|
||||
|
||||
def _parse_expression_list_or_braced_init_list(
|
||||
self
|
||||
self,
|
||||
) -> ASTParenExprList | ASTBracedInitList:
|
||||
paren = self._parse_paren_expression_list()
|
||||
if paren is not None:
|
||||
@@ -6375,7 +6375,7 @@ class DefinitionParser(BaseParser):
|
||||
return ASTDeclSpecs(outer, leftSpecs, rightSpecs, trailing)
|
||||
|
||||
def _parse_declarator_name_suffix(
|
||||
self, named: bool | str, paramMode: str, typed: bool
|
||||
self, named: bool | str, paramMode: str, typed: bool,
|
||||
) -> ASTDeclaratorNameParamQual | ASTDeclaratorNameBitField:
|
||||
# now we should parse the name, and then suffixes
|
||||
if named == 'maybe':
|
||||
@@ -6430,7 +6430,7 @@ class DefinitionParser(BaseParser):
|
||||
paramQual=paramQual)
|
||||
|
||||
def _parse_declarator(self, named: bool | str, paramMode: str,
|
||||
typed: bool = True
|
||||
typed: bool = True,
|
||||
) -> ASTDeclarator:
|
||||
# 'typed' here means 'parse return type stuff'
|
||||
if paramMode not in ('type', 'function', 'operatorCast', 'new'):
|
||||
@@ -6544,7 +6544,7 @@ class DefinitionParser(BaseParser):
|
||||
header = "Error in declarator or parameters-and-qualifiers"
|
||||
raise self._make_multi_error(prevErrors, header) from e
|
||||
|
||||
def _parse_initializer(self, outer: str = None, allowFallback: bool = True
|
||||
def _parse_initializer(self, outer: str = None, allowFallback: bool = True,
|
||||
) -> ASTInitializer:
|
||||
# initializer # global vars
|
||||
# -> brace-or-equal-initializer
|
||||
@@ -6990,7 +6990,7 @@ class DefinitionParser(BaseParser):
|
||||
else:
|
||||
return ASTRequiresClause(ASTBinOpExpr(orExprs, ops))
|
||||
|
||||
def _parse_template_declaration_prefix(self, objectType: str
|
||||
def _parse_template_declaration_prefix(self, objectType: str,
|
||||
) -> ASTTemplateDeclarationPrefix | None:
|
||||
templates: list[ASTTemplateParams | ASTTemplateIntroduction] = []
|
||||
while 1:
|
||||
@@ -7025,7 +7025,7 @@ class DefinitionParser(BaseParser):
|
||||
|
||||
def _check_template_consistency(self, nestedName: ASTNestedName,
|
||||
templatePrefix: ASTTemplateDeclarationPrefix,
|
||||
fullSpecShorthand: bool, isMember: bool = False
|
||||
fullSpecShorthand: bool, isMember: bool = False,
|
||||
) -> ASTTemplateDeclarationPrefix:
|
||||
numArgs = nestedName.num_templates()
|
||||
isMemberInstantiation = False
|
||||
@@ -7878,7 +7878,7 @@ class CPPDomain(Domain):
|
||||
'namespace-push': CPPNamespacePushObject,
|
||||
'namespace-pop': CPPNamespacePopObject,
|
||||
# other
|
||||
'alias': CPPAliasObject
|
||||
'alias': CPPAliasObject,
|
||||
}
|
||||
roles = {
|
||||
'any': CPPXRefRole(),
|
||||
@@ -7893,11 +7893,11 @@ class CPPDomain(Domain):
|
||||
'enum': CPPXRefRole(),
|
||||
'enumerator': CPPXRefRole(),
|
||||
'expr': CPPExprRole(asCode=True),
|
||||
'texpr': CPPExprRole(asCode=False)
|
||||
'texpr': CPPExprRole(asCode=False),
|
||||
}
|
||||
initial_data = {
|
||||
'root_symbol': Symbol(None, None, None, None, None, None, None),
|
||||
'names': {} # full name for indexing -> docname
|
||||
'names': {}, # full name for indexing -> docname
|
||||
}
|
||||
|
||||
def clear_doc(self, docname: str) -> None:
|
||||
@@ -8098,18 +8098,18 @@ class CPPDomain(Domain):
|
||||
# and reconstruct the title again
|
||||
contnode += nodes.Text(title)
|
||||
res = make_refnode(builder, fromdocname, docname,
|
||||
declaration.get_newest_id(), contnode, displayName
|
||||
declaration.get_newest_id(), contnode, displayName,
|
||||
), declaration.objectType
|
||||
return res
|
||||
|
||||
def resolve_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
typ: str, target: str, node: pending_xref, contnode: Element
|
||||
typ: str, target: str, node: pending_xref, contnode: Element,
|
||||
) -> Element | None:
|
||||
return self._resolve_xref_inner(env, fromdocname, builder, typ,
|
||||
target, node, contnode)[0]
|
||||
|
||||
def resolve_any_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
target: str, node: pending_xref, contnode: Element
|
||||
target: str, node: pending_xref, contnode: Element,
|
||||
) -> list[tuple[str, Element]]:
|
||||
with logging.suppress_logging():
|
||||
retnode, objtype = self._resolve_xref_inner(env, fromdocname, builder,
|
||||
|
||||
@@ -427,7 +427,7 @@ class JavaScriptDomain(Domain):
|
||||
prefix: str,
|
||||
name: str,
|
||||
typ: str | None,
|
||||
searchorder: int = 0
|
||||
searchorder: int = 0,
|
||||
) -> tuple[str | None, tuple[str, str, str] | None]:
|
||||
if name[-2:] == '()':
|
||||
name = name[:-2]
|
||||
@@ -452,7 +452,7 @@ class JavaScriptDomain(Domain):
|
||||
return newname, self.objects.get(newname)
|
||||
|
||||
def resolve_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
typ: str, target: str, node: pending_xref, contnode: Element
|
||||
typ: str, target: str, node: pending_xref, contnode: Element,
|
||||
) -> Element | None:
|
||||
mod_name = node.get('js:module')
|
||||
prefix = node.get('js:object')
|
||||
@@ -463,7 +463,7 @@ class JavaScriptDomain(Domain):
|
||||
return make_refnode(builder, fromdocname, obj[0], obj[1], contnode, name)
|
||||
|
||||
def resolve_any_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
target: str, node: pending_xref, contnode: Element
|
||||
target: str, node: pending_xref, contnode: Element,
|
||||
) -> list[tuple[str, Element]]:
|
||||
mod_name = node.get('js:module')
|
||||
prefix = node.get('js:object')
|
||||
|
||||
@@ -90,7 +90,7 @@ class MathDomain(Domain):
|
||||
self.data['has_equations'][docname] = otherdata['has_equations'][docname]
|
||||
|
||||
def resolve_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
typ: str, target: str, node: pending_xref, contnode: Element
|
||||
typ: str, target: str, node: pending_xref, contnode: Element,
|
||||
) -> Element | None:
|
||||
assert typ in ('eq', 'numref')
|
||||
result = self.equations.get(target)
|
||||
@@ -120,7 +120,7 @@ class MathDomain(Domain):
|
||||
return None
|
||||
|
||||
def resolve_any_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
target: str, node: pending_xref, contnode: Element
|
||||
target: str, node: pending_xref, contnode: Element,
|
||||
) -> list[tuple[str, Element]]:
|
||||
refnode = self.resolve_xref(env, fromdocname, builder, 'eq', target, node, contnode)
|
||||
if refnode is None:
|
||||
|
||||
@@ -75,7 +75,7 @@ class ModuleEntry(NamedTuple):
|
||||
deprecated: bool
|
||||
|
||||
|
||||
def parse_reftarget(reftarget: str, suppress_prefix: bool = False
|
||||
def parse_reftarget(reftarget: str, suppress_prefix: bool = False,
|
||||
) -> tuple[str, str, str, bool]:
|
||||
"""Parse a type string and return (reftype, reftarget, title, refspecific flag)"""
|
||||
refspecific = False
|
||||
@@ -254,7 +254,7 @@ def _parse_annotation(annotation: str, env: BuildEnvironment | None) -> list[Nod
|
||||
|
||||
|
||||
def _parse_arglist(
|
||||
arglist: str, env: BuildEnvironment | None = None
|
||||
arglist: str, env: BuildEnvironment | None = None,
|
||||
) -> addnodes.desc_parameterlist:
|
||||
"""Parse a list of arguments using AST parser"""
|
||||
params = addnodes.desc_parameterlist(arglist)
|
||||
@@ -366,7 +366,7 @@ class PyXrefMixin:
|
||||
contnode: Node | None = None,
|
||||
env: BuildEnvironment | None = None,
|
||||
inliner: Inliner | None = None,
|
||||
location: Node | None = None
|
||||
location: Node | None = None,
|
||||
) -> Node:
|
||||
# we use inliner=None to make sure we get the old behaviour with a single
|
||||
# pending_xref node
|
||||
@@ -1140,7 +1140,7 @@ class PythonModuleIndex(Index):
|
||||
localname = _('Python Module Index')
|
||||
shortname = _('modules')
|
||||
|
||||
def generate(self, docnames: Iterable[str] | None = None
|
||||
def generate(self, docnames: Iterable[str] | None = None,
|
||||
) -> tuple[list[tuple[str, list[IndexEntry]]], bool]:
|
||||
content: dict[str, list[IndexEntry]] = {}
|
||||
# list of prefixes to ignore
|
||||
@@ -1310,7 +1310,7 @@ class PythonDomain(Domain):
|
||||
self.modules[modname] = mod
|
||||
|
||||
def find_obj(self, env: BuildEnvironment, modname: str, classname: str,
|
||||
name: str, type: str | None, searchmode: int = 0
|
||||
name: str, type: str | None, searchmode: int = 0,
|
||||
) -> list[tuple[str, ObjectEntry]]:
|
||||
"""Find a Python object for "name", perhaps using the given module
|
||||
and/or classname. Returns a list of (name, object entry) tuples.
|
||||
@@ -1366,7 +1366,7 @@ class PythonDomain(Domain):
|
||||
return matches
|
||||
|
||||
def resolve_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
type: str, target: str, node: pending_xref, contnode: Element
|
||||
type: str, target: str, node: pending_xref, contnode: Element,
|
||||
) -> Element | None:
|
||||
modname = node.get('py:module')
|
||||
clsname = node.get('py:class')
|
||||
@@ -1413,7 +1413,7 @@ class PythonDomain(Domain):
|
||||
return make_refnode(builder, fromdocname, obj[0], obj[1], children, name)
|
||||
|
||||
def resolve_any_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
target: str, node: pending_xref, contnode: Element
|
||||
target: str, node: pending_xref, contnode: Element,
|
||||
) -> list[tuple[str, Element]]:
|
||||
modname = node.get('py:module')
|
||||
clsname = node.get('py:class')
|
||||
|
||||
@@ -263,7 +263,7 @@ class ReSTDomain(Domain):
|
||||
self.objects[typ, name] = (doc, node_id)
|
||||
|
||||
def resolve_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
typ: str, target: str, node: pending_xref, contnode: Element
|
||||
typ: str, target: str, node: pending_xref, contnode: Element,
|
||||
) -> Element | None:
|
||||
objtypes = self.objtypes_for_role(typ)
|
||||
for objtype in objtypes:
|
||||
@@ -275,7 +275,7 @@ class ReSTDomain(Domain):
|
||||
return None
|
||||
|
||||
def resolve_any_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
target: str, node: pending_xref, contnode: Element
|
||||
target: str, node: pending_xref, contnode: Element,
|
||||
) -> list[tuple[str, Element]]:
|
||||
results: list[tuple[str, Element]] = []
|
||||
for objtype in self.object_types:
|
||||
|
||||
@@ -99,7 +99,7 @@ class EnvVarXRefRole(XRefRole):
|
||||
indexnode = addnodes.index()
|
||||
indexnode['entries'] = [
|
||||
('single', varname, tgtid, '', None),
|
||||
('single', _('environment variable; %s') % varname, tgtid, '', None)
|
||||
('single', _('environment variable; %s') % varname, tgtid, '', None),
|
||||
]
|
||||
targetnode = nodes.target('', '', ids=[tgtid])
|
||||
document.note_explicit_target(targetnode)
|
||||
@@ -292,7 +292,7 @@ def split_term_classifiers(line: str) -> list[str | None]:
|
||||
|
||||
|
||||
def make_glossary_term(env: BuildEnvironment, textnodes: Iterable[Node], index_key: str,
|
||||
source: str, lineno: int, node_id: str | None, document: nodes.document
|
||||
source: str, lineno: int, node_id: str | None, document: nodes.document,
|
||||
) -> nodes.term:
|
||||
# get a text-only representation of the term and register it
|
||||
# as a cross-reference target
|
||||
@@ -553,7 +553,7 @@ class StandardDomain(Domain):
|
||||
searchprio=-1),
|
||||
'envvar': ObjType(_('environment variable'), 'envvar'),
|
||||
'cmdoption': ObjType(_('program option'), 'option'),
|
||||
'doc': ObjType(_('document'), 'doc', searchprio=-1)
|
||||
'doc': ObjType(_('document'), 'doc', searchprio=-1),
|
||||
}
|
||||
|
||||
directives: dict[str, type[Directive]] = {
|
||||
@@ -656,7 +656,7 @@ class StandardDomain(Domain):
|
||||
def objects(self) -> dict[tuple[str, str], tuple[str, str]]:
|
||||
return self.data.setdefault('objects', {}) # (objtype, name) -> docname, labelid
|
||||
|
||||
def note_object(self, objtype: str, name: str, labelid: str, location: Any = None
|
||||
def note_object(self, objtype: str, name: str, labelid: str, location: Any = None,
|
||||
) -> None:
|
||||
"""Note a generic object for cross reference.
|
||||
|
||||
@@ -731,7 +731,7 @@ class StandardDomain(Domain):
|
||||
self.anonlabels[key] = data
|
||||
|
||||
def process_doc(
|
||||
self, env: BuildEnvironment, docname: str, document: nodes.document
|
||||
self, env: BuildEnvironment, docname: str, document: nodes.document,
|
||||
) -> None:
|
||||
for name, explicit in document.nametypes.items():
|
||||
if not explicit:
|
||||
@@ -788,7 +788,7 @@ class StandardDomain(Domain):
|
||||
self.progoptions[program, name] = (docname, labelid)
|
||||
|
||||
def build_reference_node(self, fromdocname: str, builder: Builder, docname: str,
|
||||
labelid: str, sectname: str, rolename: str, **options: Any
|
||||
labelid: str, sectname: str, rolename: str, **options: Any,
|
||||
) -> Element:
|
||||
nodeclass = options.pop('nodeclass', nodes.reference)
|
||||
newnode = nodeclass('', '', internal=True, **options)
|
||||
@@ -813,7 +813,7 @@ class StandardDomain(Domain):
|
||||
return newnode
|
||||
|
||||
def resolve_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
typ: str, target: str, node: pending_xref, contnode: Element
|
||||
typ: str, target: str, node: pending_xref, contnode: Element,
|
||||
) -> Element | None:
|
||||
if typ == 'ref':
|
||||
resolver = self._resolve_ref_xref
|
||||
@@ -1090,7 +1090,7 @@ class StandardDomain(Domain):
|
||||
builder: Builder,
|
||||
figtype: str,
|
||||
docname: str,
|
||||
target_node: Element
|
||||
target_node: Element,
|
||||
) -> tuple[int, ...] | None:
|
||||
if figtype == 'section':
|
||||
if builder.name == 'latex':
|
||||
@@ -1128,7 +1128,7 @@ class StandardDomain(Domain):
|
||||
return None
|
||||
|
||||
|
||||
def warn_missing_reference(app: Sphinx, domain: Domain, node: pending_xref
|
||||
def warn_missing_reference(app: Sphinx, domain: Domain, node: pending_xref,
|
||||
) -> bool | None:
|
||||
if (domain and domain.name != 'std') or node['reftype'] != 'ref':
|
||||
return None
|
||||
|
||||
@@ -605,7 +605,7 @@ class BuildEnvironment:
|
||||
builder: Builder,
|
||||
doctree: nodes.document | None = None,
|
||||
prune_toctrees: bool = True,
|
||||
includehidden: bool = False
|
||||
includehidden: bool = False,
|
||||
) -> nodes.document:
|
||||
"""Read the doctree from the pickle, resolve cross-references and
|
||||
toctrees and return it.
|
||||
@@ -676,7 +676,7 @@ class BuildEnvironment:
|
||||
traversed = set()
|
||||
|
||||
def traverse_toctree(
|
||||
parent: str | None, docname: str
|
||||
parent: str | None, docname: str,
|
||||
) -> Iterator[tuple[str | None, str]]:
|
||||
if parent == docname:
|
||||
logger.warning(__('self referenced toctree found. Ignored.'),
|
||||
|
||||
@@ -22,7 +22,7 @@ class IndexEntries:
|
||||
self.env = env
|
||||
|
||||
def create_index(self, builder: Builder, group_entries: bool = True,
|
||||
_fixre: re.Pattern = re.compile(r'(.*) ([(][^()]*[)])')
|
||||
_fixre: re.Pattern = re.compile(r'(.*) ([(][^()]*[)])'),
|
||||
) -> list[tuple[str, list[tuple[str, Any]]]]:
|
||||
"""Create the real index from the collected index entries."""
|
||||
new: dict[str, list] = {}
|
||||
|
||||
@@ -214,7 +214,7 @@ class TocTree:
|
||||
for i, entry in enumerate(
|
||||
_entries_from_toctree(sub_toc_node, [refdoc] + parents,
|
||||
subtree=True),
|
||||
start=sub_toc_node.parent.index(sub_toc_node) + 1
|
||||
start=sub_toc_node.parent.index(sub_toc_node) + 1,
|
||||
):
|
||||
sub_toc_node.parent.insert(i, entry)
|
||||
sub_toc_node.parent.remove(sub_toc_node)
|
||||
|
||||
@@ -58,7 +58,7 @@ class TocTreeCollector(EnvironmentCollector):
|
||||
|
||||
def build_toc(
|
||||
node: Element | Sequence[Element],
|
||||
depth: int = 1
|
||||
depth: int = 1,
|
||||
) -> nodes.bullet_list | None:
|
||||
# list of table of contents entries
|
||||
entries: list[Element] = []
|
||||
@@ -171,7 +171,7 @@ class TocTreeCollector(EnvironmentCollector):
|
||||
env.toc_secnumbers = {}
|
||||
|
||||
def _walk_toc(
|
||||
node: Element, secnums: dict, depth: int, titlenode: nodes.title | None = None
|
||||
node: Element, secnums: dict, depth: int, titlenode: nodes.title | None = None,
|
||||
) -> None:
|
||||
# titlenode is the title of the document, it will get assigned a
|
||||
# secnumber too, so that it shows up in next/prev/parent rellinks
|
||||
|
||||
@@ -42,7 +42,7 @@ class ExtensionError(SphinxError):
|
||||
"""Extension error."""
|
||||
|
||||
def __init__(
|
||||
self, message: str, orig_exc: Exception | None = None, modname: str | None = None
|
||||
self, message: str, orig_exc: Exception | None = None, modname: str | None = None,
|
||||
) -> None:
|
||||
super().__init__(message)
|
||||
self.message = message
|
||||
|
||||
@@ -108,7 +108,7 @@ def create_module_file(package: str, basename: str, opts: Any,
|
||||
|
||||
def create_package_file(root: str, master_package: str, subroot: str, py_files: list[str],
|
||||
opts: Any, subs: list[str], is_namespace: bool,
|
||||
excludes: list[str] = [], user_template_dir: str | None = None
|
||||
excludes: list[str] = [], user_template_dir: str | None = None,
|
||||
) -> None:
|
||||
"""Build the text of the file and write the file."""
|
||||
# build a list of sub packages (directories containing an __init__ file)
|
||||
@@ -193,7 +193,7 @@ def is_skipped_module(filename: str, opts: Any, excludes: list[str]) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def walk(rootpath: str, excludes: list[str], opts: Any
|
||||
def walk(rootpath: str, excludes: list[str], opts: Any,
|
||||
) -> Generator[tuple[str, list[str], list[str]], None, None]:
|
||||
"""Walk through the directory and list files and subdirectories up."""
|
||||
followlinks = getattr(opts, 'followlinks', False)
|
||||
|
||||
@@ -189,7 +189,7 @@ def cut_lines(pre: int, post: int = 0, what: str | None = None) -> Callable:
|
||||
|
||||
This can (and should) be used in place of :confval:`automodule_skip_lines`.
|
||||
"""
|
||||
def process(app: Sphinx, what_: str, name: str, obj: Any, options: Any, lines: list[str]
|
||||
def process(app: Sphinx, what_: str, name: str, obj: Any, options: Any, lines: list[str],
|
||||
) -> None:
|
||||
if what and what_ not in what:
|
||||
return
|
||||
@@ -209,7 +209,7 @@ def between(
|
||||
marker: str,
|
||||
what: Sequence[str] | None = None,
|
||||
keepempty: bool = False,
|
||||
exclude: bool = False
|
||||
exclude: bool = False,
|
||||
) -> Callable:
|
||||
"""Return a listener that either keeps, or if *exclude* is True excludes,
|
||||
lines between lines that match the *marker* regular expression. If no line
|
||||
@@ -221,7 +221,7 @@ def between(
|
||||
"""
|
||||
marker_re = re.compile(marker)
|
||||
|
||||
def process(app: Sphinx, what_: str, name: str, obj: Any, options: Any, lines: list[str]
|
||||
def process(app: Sphinx, what_: str, name: str, obj: Any, options: Any, lines: list[str],
|
||||
) -> None:
|
||||
if what and what_ not in what:
|
||||
return
|
||||
@@ -316,7 +316,7 @@ class Documenter:
|
||||
titles_allowed = True
|
||||
|
||||
option_spec: OptionSpec = {
|
||||
'noindex': bool_option
|
||||
'noindex': bool_option,
|
||||
}
|
||||
|
||||
def get_attr(self, obj: Any, name: str, *defargs: Any) -> Any:
|
||||
@@ -324,7 +324,7 @@ class Documenter:
|
||||
return autodoc_attrgetter(self.env.app, obj, name, *defargs)
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any,
|
||||
) -> bool:
|
||||
"""Called to see if a member can be documented by this Documenter."""
|
||||
raise NotImplementedError('must be implemented in subclasses')
|
||||
@@ -366,7 +366,7 @@ class Documenter:
|
||||
else:
|
||||
self.directive.result.append('', source, *lineno)
|
||||
|
||||
def resolve_name(self, modname: str, parents: Any, path: str, base: Any
|
||||
def resolve_name(self, modname: str, parents: Any, path: str, base: Any,
|
||||
) -> tuple[str, list[str]]:
|
||||
"""Resolve the module and name of the object to document given by the
|
||||
arguments and the current module/class.
|
||||
@@ -634,7 +634,7 @@ class Documenter:
|
||||
"""
|
||||
raise NotImplementedError('must be implemented in subclasses')
|
||||
|
||||
def filter_members(self, members: ObjectMembers, want_all: bool
|
||||
def filter_members(self, members: ObjectMembers, want_all: bool,
|
||||
) -> list[tuple[str, Any, bool]]:
|
||||
"""Filter the given member list.
|
||||
|
||||
@@ -856,7 +856,7 @@ class Documenter:
|
||||
more_content: StringList | None = None,
|
||||
real_modname: str | None = None,
|
||||
check_module: bool = False,
|
||||
all_members: bool = False
|
||||
all_members: bool = False,
|
||||
) -> None:
|
||||
"""Generate reST for the object given by *self.name*, and possibly for
|
||||
its members.
|
||||
@@ -984,12 +984,12 @@ class ModuleDocumenter(Documenter):
|
||||
self.add_line(line, src[0], src[1])
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any,
|
||||
) -> bool:
|
||||
# don't document submodules automatically
|
||||
return False
|
||||
|
||||
def resolve_name(self, modname: str, parents: Any, path: str, base: Any
|
||||
def resolve_name(self, modname: str, parents: Any, path: str, base: Any,
|
||||
) -> tuple[str, list[str]]:
|
||||
if modname is not None:
|
||||
logger.warning(__('"::" in automodule name doesn\'t make sense'),
|
||||
@@ -1109,7 +1109,7 @@ class ModuleLevelDocumenter(Documenter):
|
||||
Specialized Documenter subclass for objects on module level (functions,
|
||||
classes, data/constants).
|
||||
"""
|
||||
def resolve_name(self, modname: str, parents: Any, path: str, base: Any
|
||||
def resolve_name(self, modname: str, parents: Any, path: str, base: Any,
|
||||
) -> tuple[str, list[str]]:
|
||||
if modname is None:
|
||||
if path:
|
||||
@@ -1130,7 +1130,7 @@ class ClassLevelDocumenter(Documenter):
|
||||
Specialized Documenter subclass for objects on class level (methods,
|
||||
attributes).
|
||||
"""
|
||||
def resolve_name(self, modname: str, parents: Any, path: str, base: Any
|
||||
def resolve_name(self, modname: str, parents: Any, path: str, base: Any,
|
||||
) -> tuple[str, list[str]]:
|
||||
if modname is None:
|
||||
if path:
|
||||
@@ -1265,7 +1265,7 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ
|
||||
member_order = 30
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any,
|
||||
) -> bool:
|
||||
# supports functions, builtins and bound methods exported at the module level
|
||||
return (inspect.isfunction(member) or inspect.isbuiltin(member) or
|
||||
@@ -1454,7 +1454,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
||||
merge_members_option(self.options)
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any,
|
||||
) -> bool:
|
||||
return isinstance(member, type) or (
|
||||
isattr and (inspect.isNewType(member) or isinstance(member, TypeVar)))
|
||||
@@ -1829,7 +1829,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
||||
|
||||
more_content = StringList(
|
||||
[_('alias of TypeVar(%s)') % ", ".join(attrs), ''],
|
||||
source=''
|
||||
source='',
|
||||
)
|
||||
if self.doc_as_attr and self.modname != self.get_real_modname():
|
||||
try:
|
||||
@@ -1861,7 +1861,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type:
|
||||
more_content: StringList | None = None,
|
||||
real_modname: str | None = None,
|
||||
check_module: bool = False,
|
||||
all_members: bool = False
|
||||
all_members: bool = False,
|
||||
) -> None:
|
||||
# Do not pass real_modname and use the name from the __module__
|
||||
# attribute of the class.
|
||||
@@ -1884,7 +1884,7 @@ class ExceptionDocumenter(ClassDocumenter):
|
||||
priority = ClassDocumenter.priority + 5
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any,
|
||||
) -> bool:
|
||||
return isinstance(member, type) and issubclass(member, BaseException)
|
||||
|
||||
@@ -1988,7 +1988,7 @@ class DataDocumenter(GenericAliasMixin,
|
||||
option_spec["no-value"] = bool_option
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any,
|
||||
) -> bool:
|
||||
return isinstance(parent, ModuleDocumenter) and isattr
|
||||
|
||||
@@ -2105,7 +2105,7 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type:
|
||||
priority = 1 # must be more than FunctionDocumenter
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any,
|
||||
) -> bool:
|
||||
return inspect.isroutine(member) and not isinstance(parent, ModuleDocumenter)
|
||||
|
||||
@@ -2535,7 +2535,7 @@ class AttributeDocumenter(GenericAliasMixin, SlotsMixin, # type: ignore
|
||||
return inspect.isfunction(obj) or inspect.isbuiltin(obj) or inspect.ismethod(obj)
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any,
|
||||
) -> bool:
|
||||
if isinstance(parent, ModuleDocumenter):
|
||||
return False
|
||||
@@ -2681,7 +2681,7 @@ class PropertyDocumenter(DocstringStripSignatureMixin, ClassLevelDocumenter): #
|
||||
priority = AttributeDocumenter.priority + 1
|
||||
|
||||
@classmethod
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any
|
||||
def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any,
|
||||
) -> bool:
|
||||
if isinstance(parent, ClassDocumenter):
|
||||
if inspect.isproperty(member):
|
||||
|
||||
@@ -53,7 +53,7 @@ class DocumenterBridge:
|
||||
self.state = state
|
||||
|
||||
|
||||
def process_documenter_options(documenter: type[Documenter], config: Config, options: dict
|
||||
def process_documenter_options(documenter: type[Documenter], config: Config, options: dict,
|
||||
) -> Options:
|
||||
"""Recognize options of Documenter from user input."""
|
||||
for name in AUTODOC_DEFAULT_OPTIONS:
|
||||
@@ -79,7 +79,7 @@ def process_documenter_options(documenter: type[Documenter], config: Config, opt
|
||||
return Options(assemble_option_dict(options.items(), documenter.option_spec))
|
||||
|
||||
|
||||
def parse_generated_content(state: RSTState, content: StringList, documenter: Documenter
|
||||
def parse_generated_content(state: RSTState, content: StringList, documenter: Documenter,
|
||||
) -> list[Node]:
|
||||
"""Parse an item of content generated by Documenter."""
|
||||
with switch_source_input(state, content):
|
||||
|
||||
@@ -153,7 +153,7 @@ def get_object_members(
|
||||
subject: Any,
|
||||
objpath: list[str],
|
||||
attrgetter: Callable,
|
||||
analyzer: ModuleAnalyzer | None = None
|
||||
analyzer: ModuleAnalyzer | None = None,
|
||||
) -> dict[str, Attribute]:
|
||||
"""Get members and attributes of target object."""
|
||||
from sphinx.ext.autodoc import INSTANCEATTR
|
||||
|
||||
@@ -120,5 +120,5 @@ def setup(app: Sphinx) -> dict[str, Any]:
|
||||
|
||||
return {
|
||||
'version': sphinx.__display_version__,
|
||||
'parallel_read_safe': True
|
||||
'parallel_read_safe': True,
|
||||
}
|
||||
|
||||
@@ -69,11 +69,11 @@ def merge_typehints(app: Sphinx, domain: str, objtype: str, contentnode: Element
|
||||
modify_field_list(field_list, annotations[fullname])
|
||||
elif app.config.autodoc_typehints_description_target == "documented_params":
|
||||
augment_descriptions_with_types(
|
||||
field_list, annotations[fullname], force_rtype=True
|
||||
field_list, annotations[fullname], force_rtype=True,
|
||||
)
|
||||
else:
|
||||
augment_descriptions_with_types(
|
||||
field_list, annotations[fullname], force_rtype=False
|
||||
field_list, annotations[fullname], force_rtype=False,
|
||||
)
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ def modify_field_list(node: nodes.field_list, annotations: dict[str, str],
|
||||
def augment_descriptions_with_types(
|
||||
node: nodes.field_list,
|
||||
annotations: dict[str, str],
|
||||
force_rtype: bool
|
||||
force_rtype: bool,
|
||||
) -> None:
|
||||
fields = cast(Iterable[nodes.field], node)
|
||||
has_description: set[str] = set()
|
||||
|
||||
@@ -270,7 +270,7 @@ class Autosummary(SphinxDirective):
|
||||
return nodes
|
||||
|
||||
def import_by_name(
|
||||
self, name: str, prefixes: list[str | None]
|
||||
self, name: str, prefixes: list[str | None],
|
||||
) -> tuple[str, Any, Any, str]:
|
||||
with mock(self.config.autosummary_mock_imports):
|
||||
try:
|
||||
@@ -627,7 +627,7 @@ def get_import_prefixes_from_env(env: BuildEnvironment) -> list[str | None]:
|
||||
|
||||
|
||||
def import_by_name(
|
||||
name: str, prefixes: list[str | None] = [None], grouped_exception: bool = True
|
||||
name: str, prefixes: list[str | None] = [None], grouped_exception: bool = True,
|
||||
) -> tuple[str, Any, Any, str]:
|
||||
"""Import a Python object that has the given *name*, under one of the
|
||||
*prefixes*. The first name that succeeds is used.
|
||||
|
||||
@@ -472,7 +472,7 @@ def find_autosummary_in_files(filenames: list[str]) -> list[AutosummaryEntry]:
|
||||
|
||||
|
||||
def find_autosummary_in_docstring(
|
||||
name: str, filename: str | None = None
|
||||
name: str, filename: str | None = None,
|
||||
) -> list[AutosummaryEntry]:
|
||||
"""Find out what items are documented in the given object's docstring.
|
||||
|
||||
@@ -494,7 +494,7 @@ def find_autosummary_in_docstring(
|
||||
|
||||
|
||||
def find_autosummary_in_lines(
|
||||
lines: list[str], module: str | None = None, filename: str | None = None
|
||||
lines: list[str], module: str | None = None, filename: str | None = None,
|
||||
) -> list[AutosummaryEntry]:
|
||||
"""Find out what items appear in autosummary:: directives in the
|
||||
given lines.
|
||||
|
||||
@@ -141,13 +141,13 @@ class TestDirective(SphinxDirective):
|
||||
|
||||
class TestsetupDirective(TestDirective):
|
||||
option_spec: OptionSpec = {
|
||||
'skipif': directives.unchanged_required
|
||||
'skipif': directives.unchanged_required,
|
||||
}
|
||||
|
||||
|
||||
class TestcleanupDirective(TestDirective):
|
||||
option_spec: OptionSpec = {
|
||||
'skipif': directives.unchanged_required
|
||||
'skipif': directives.unchanged_required,
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ class TestCode:
|
||||
|
||||
|
||||
class SphinxDocTestRunner(doctest.DocTestRunner):
|
||||
def summarize(self, out: Callable, verbose: bool = None # type: ignore
|
||||
def summarize(self, out: Callable, verbose: bool = None, # type: ignore
|
||||
) -> tuple[int, int]:
|
||||
string_io = StringIO()
|
||||
old_stdout = sys.stdout
|
||||
|
||||
@@ -91,7 +91,7 @@ def make_link_role(name: str, base_url: str, caption: str) -> RoleFunction:
|
||||
# Remark: It is an implementation detail that we use Pythons %-formatting.
|
||||
# So far we only expose ``%s`` and require quoting of ``%`` using ``%%``.
|
||||
def role(typ: str, rawtext: str, text: str, lineno: int,
|
||||
inliner: Inliner, options: dict = {}, content: list[str] = []
|
||||
inliner: Inliner, options: dict = {}, content: list[str] = [],
|
||||
) -> tuple[list[Node], list[system_message]]:
|
||||
text = utils.unescape(text)
|
||||
has_explicit_title, title, part = split_explicit_title(text)
|
||||
|
||||
@@ -212,7 +212,7 @@ class GraphvizSimple(SphinxDirective):
|
||||
|
||||
|
||||
def render_dot(self: SphinxTranslator, code: str, options: dict, format: str,
|
||||
prefix: str = 'graphviz', filename: str | None = None
|
||||
prefix: str = 'graphviz', filename: str | None = None,
|
||||
) -> tuple[str | None, str | None]:
|
||||
"""Render graphviz code into a PNG or PDF output file."""
|
||||
graphviz_dot = options.get('graphviz_dot', self.builder.config.graphviz_dot)
|
||||
@@ -266,7 +266,7 @@ def render_dot(self: SphinxTranslator, code: str, options: dict, format: str,
|
||||
|
||||
def render_dot_html(self: HTML5Translator, node: graphviz, code: str, options: dict,
|
||||
prefix: str = 'graphviz', imgcls: str | None = None,
|
||||
alt: str | None = None, filename: str | None = None
|
||||
alt: str | None = None, filename: str | None = None,
|
||||
) -> tuple[str, str]:
|
||||
format = self.builder.config.graphviz_output_format
|
||||
try:
|
||||
@@ -322,7 +322,7 @@ def html_visit_graphviz(self: HTML5Translator, node: graphviz) -> None:
|
||||
|
||||
|
||||
def render_dot_latex(self: LaTeXTranslator, node: graphviz, code: str,
|
||||
options: dict, prefix: str = 'graphviz', filename: str | None = None
|
||||
options: dict, prefix: str = 'graphviz', filename: str | None = None,
|
||||
) -> None:
|
||||
try:
|
||||
fname, outfn = render_dot(self, code, options, 'pdf', prefix, filename)
|
||||
|
||||
@@ -38,7 +38,7 @@ class ImagemagickConverter(ImageConverter):
|
||||
"'sphinx.ext.imgconverter' requires ImageMagick by default. "
|
||||
"Ensure it is installed, or set the 'image_converter' option "
|
||||
"to a custom conversion command.\n\n"
|
||||
"Traceback: %s"
|
||||
"Traceback: %s",
|
||||
), self.config.image_converter, exc)
|
||||
return False
|
||||
except CalledProcessError as exc:
|
||||
|
||||
@@ -39,7 +39,7 @@ class MathExtError(SphinxError):
|
||||
category = 'Math extension error'
|
||||
|
||||
def __init__(
|
||||
self, msg: str, stderr: str | None = None, stdout: str | None = None
|
||||
self, msg: str, stderr: str | None = None, stdout: str | None = None,
|
||||
) -> None:
|
||||
if stderr:
|
||||
msg += '\n[stderr]\n' + stderr
|
||||
@@ -87,7 +87,7 @@ def generate_latex_macro(image_format: str,
|
||||
'baselineskip': int(round(config.imgmath_font_size * 1.2)),
|
||||
'preamble': config.imgmath_latex_preamble,
|
||||
'tightpage': '' if image_format == 'png' else ',tightpage',
|
||||
'math': math
|
||||
'math': math,
|
||||
}
|
||||
|
||||
if config.imgmath_use_preview:
|
||||
|
||||
@@ -139,7 +139,7 @@ class InheritanceGraph:
|
||||
"""
|
||||
def __init__(self, class_names: list[str], currmodule: str, show_builtins: bool = False,
|
||||
private_bases: bool = False, parts: int = 0,
|
||||
aliases: dict[str, str] | None = None, top_classes: list[Any] = []
|
||||
aliases: dict[str, str] | None = None, top_classes: list[Any] = [],
|
||||
) -> None:
|
||||
"""*class_names* is a list of child classes to show bases from.
|
||||
|
||||
@@ -162,7 +162,7 @@ class InheritanceGraph:
|
||||
return classes
|
||||
|
||||
def _class_info(self, classes: list[Any], show_builtins: bool, private_bases: bool,
|
||||
parts: int, aliases: dict[str, str], top_classes: list[Any]
|
||||
parts: int, aliases: dict[str, str], top_classes: list[Any],
|
||||
) -> list[tuple[str, str, list[str], str]]:
|
||||
"""Return name and bases for all classes that are ancestors of
|
||||
*classes*.
|
||||
@@ -221,7 +221,7 @@ class InheritanceGraph:
|
||||
return list(all_classes.values())
|
||||
|
||||
def class_name(
|
||||
self, cls: Any, parts: int = 0, aliases: dict[str, str] | None = None
|
||||
self, cls: Any, parts: int = 0, aliases: dict[str, str] | None = None,
|
||||
) -> str:
|
||||
"""Given a class object, return a fully-qualified name.
|
||||
|
||||
@@ -274,7 +274,7 @@ class InheritanceGraph:
|
||||
|
||||
def generate_dot(self, name: str, urls: dict[str, str] = {},
|
||||
env: BuildEnvironment | None = None,
|
||||
graph_attrs: dict = {}, node_attrs: dict = {}, edge_attrs: dict = {}
|
||||
graph_attrs: dict = {}, node_attrs: dict = {}, edge_attrs: dict = {},
|
||||
) -> str:
|
||||
"""Generate a graphviz dot graph from the classes that were passed in
|
||||
to __init__.
|
||||
@@ -442,7 +442,7 @@ def latex_visit_inheritance_diagram(self: LaTeXTranslator, node: inheritance_dia
|
||||
raise nodes.SkipNode
|
||||
|
||||
|
||||
def texinfo_visit_inheritance_diagram(self: TexinfoTranslator, node: inheritance_diagram
|
||||
def texinfo_visit_inheritance_diagram(self: TexinfoTranslator, node: inheritance_diagram,
|
||||
) -> None:
|
||||
"""
|
||||
Output the graph for Texinfo. This will insert a PNG.
|
||||
|
||||
@@ -192,7 +192,7 @@ def fetch_inventory(app: Sphinx, uri: str, inv: Any) -> Any:
|
||||
|
||||
|
||||
def fetch_inventory_group(
|
||||
name: str, uri: str, invs: Any, cache: Any, app: Any, now: float
|
||||
name: str, uri: str, invs: Any, cache: Any, app: Any, now: float,
|
||||
) -> bool:
|
||||
cache_time = now - app.config.intersphinx_cache_limit * 86400
|
||||
failures = []
|
||||
@@ -237,7 +237,7 @@ def load_mappings(app: Sphinx) -> None:
|
||||
futures = []
|
||||
for name, (uri, invs) in app.config.intersphinx_mapping.values():
|
||||
futures.append(pool.submit(
|
||||
fetch_inventory_group, name, uri, invs, inventories.cache, app, now
|
||||
fetch_inventory_group, name, uri, invs, inventories.cache, app, now,
|
||||
))
|
||||
updated = [f.result() for f in concurrent.futures.as_completed(futures)]
|
||||
|
||||
@@ -327,7 +327,7 @@ def _resolve_reference_in_domain(env: BuildEnvironment,
|
||||
inv_name: str | None, inventory: Inventory,
|
||||
honor_disabled_refs: bool,
|
||||
domain: Domain, objtypes: list[str],
|
||||
node: pending_xref, contnode: TextElement
|
||||
node: pending_xref, contnode: TextElement,
|
||||
) -> Element | None:
|
||||
# we adjust the object types for backwards compatibility
|
||||
if domain.name == 'std' and 'cmdoption' in objtypes:
|
||||
@@ -406,7 +406,7 @@ def inventory_exists(env: BuildEnvironment, inv_name: str) -> bool:
|
||||
|
||||
def resolve_reference_in_inventory(env: BuildEnvironment,
|
||||
inv_name: str,
|
||||
node: pending_xref, contnode: TextElement
|
||||
node: pending_xref, contnode: TextElement,
|
||||
) -> Element | None:
|
||||
"""Attempt to resolve a missing reference via intersphinx references.
|
||||
|
||||
@@ -421,7 +421,7 @@ def resolve_reference_in_inventory(env: BuildEnvironment,
|
||||
|
||||
def resolve_reference_any_inventory(env: BuildEnvironment,
|
||||
honor_disabled_refs: bool,
|
||||
node: pending_xref, contnode: TextElement
|
||||
node: pending_xref, contnode: TextElement,
|
||||
) -> Element | None:
|
||||
"""Attempt to resolve a missing reference via intersphinx references.
|
||||
|
||||
@@ -433,7 +433,7 @@ def resolve_reference_any_inventory(env: BuildEnvironment,
|
||||
|
||||
|
||||
def resolve_reference_detect_inventory(env: BuildEnvironment,
|
||||
node: pending_xref, contnode: TextElement
|
||||
node: pending_xref, contnode: TextElement,
|
||||
) -> Element | None:
|
||||
"""Attempt to resolve a missing reference via intersphinx references.
|
||||
|
||||
@@ -474,8 +474,9 @@ class IntersphinxDispatcher(CustomReSTDispatcher):
|
||||
This enables :external:***:/:external+***: roles on parsing reST document.
|
||||
"""
|
||||
|
||||
def role(self, role_name: str, language_module: ModuleType, lineno: int, reporter: Reporter
|
||||
) -> tuple[RoleFunction, list[system_message]]:
|
||||
def role(
|
||||
self, role_name: str, language_module: ModuleType, lineno: int, reporter: Reporter,
|
||||
) -> tuple[RoleFunction, list[system_message]]:
|
||||
if len(role_name) > 9 and role_name.startswith(('external:', 'external+')):
|
||||
return IntersphinxRole(role_name), []
|
||||
else:
|
||||
@@ -640,7 +641,7 @@ def setup(app: Sphinx) -> dict[str, Any]:
|
||||
return {
|
||||
'version': sphinx.__display_version__,
|
||||
'env_version': 1,
|
||||
'parallel_read_safe': True
|
||||
'parallel_read_safe': True,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ _xref_or_code_regex = re.compile(
|
||||
r'((?::(?:[a-zA-Z0-9]+[\-_+:.])*[a-zA-Z0-9]+:`.+?`)|'
|
||||
r'(?:``.+?``))')
|
||||
_xref_regex = re.compile(
|
||||
r'(?:(?::(?:[a-zA-Z0-9]+[\-_+:.])*[a-zA-Z0-9]+:)?`.+?`)'
|
||||
r'(?:(?::(?:[a-zA-Z0-9]+[\-_+:.])*[a-zA-Z0-9]+:)?`.+?`)',
|
||||
)
|
||||
_bullet_list_regex = re.compile(r'^(\*|\+|\-)(\s+\S|\s*$)')
|
||||
_enumerated_list_regex = re.compile(
|
||||
@@ -36,7 +36,7 @@ _token_regex = re.compile(
|
||||
r"(,\sor\s|\sor\s|\sof\s|:\s|\sto\s|,\sand\s|\sand\s|,\s"
|
||||
r"|[{]|[}]"
|
||||
r'|"(?:\\"|[^"])*"'
|
||||
r"|'(?:\\'|[^'])*')"
|
||||
r"|'(?:\\'|[^'])*')",
|
||||
)
|
||||
_default_regex = re.compile(
|
||||
r"^default[^_0-9A-Za-z].*$",
|
||||
@@ -154,7 +154,7 @@ class GoogleDocstring:
|
||||
what: str = '',
|
||||
name: str = '',
|
||||
obj: Any = None,
|
||||
options: Any = None
|
||||
options: Any = None,
|
||||
) -> None:
|
||||
self._config = config
|
||||
self._app = app
|
||||
@@ -278,7 +278,7 @@ class GoogleDocstring:
|
||||
line = self._lines.get(0)
|
||||
return lines
|
||||
|
||||
def _consume_field(self, parse_type: bool = True, prefer_type: bool = False
|
||||
def _consume_field(self, parse_type: bool = True, prefer_type: bool = False,
|
||||
) -> tuple[str, str, list[str]]:
|
||||
line = self._lines.next()
|
||||
|
||||
@@ -327,7 +327,7 @@ class GoogleDocstring:
|
||||
_descs = self.__class__(_descs, self._config).lines()
|
||||
return _type, _descs
|
||||
|
||||
def _consume_returns_section(self, preprocess_types: bool = False
|
||||
def _consume_returns_section(self, preprocess_types: bool = False,
|
||||
) -> list[tuple[str, str, list[str]]]:
|
||||
lines = self._dedent(self._consume_to_next_section())
|
||||
if lines:
|
||||
@@ -417,7 +417,7 @@ class GoogleDocstring:
|
||||
return ['.. %s::' % admonition, '']
|
||||
|
||||
def _format_block(
|
||||
self, prefix: str, lines: list[str], padding: str | None = None
|
||||
self, prefix: str, lines: list[str], padding: str | None = None,
|
||||
) -> list[str]:
|
||||
if lines:
|
||||
if padding is None:
|
||||
@@ -435,7 +435,7 @@ class GoogleDocstring:
|
||||
return [prefix]
|
||||
|
||||
def _format_docutils_params(self, fields: list[tuple[str, str, list[str]]],
|
||||
field_role: str = 'param', type_role: str = 'type'
|
||||
field_role: str = 'param', type_role: str = 'type',
|
||||
) -> list[str]:
|
||||
lines = []
|
||||
for _name, _type, _desc in fields:
|
||||
@@ -480,7 +480,7 @@ class GoogleDocstring:
|
||||
else:
|
||||
return [field]
|
||||
|
||||
def _format_fields(self, field_type: str, fields: list[tuple[str, str, list[str]]]
|
||||
def _format_fields(self, field_type: str, fields: list[tuple[str, str, list[str]]],
|
||||
) -> list[str]:
|
||||
field_type = ':%s:' % field_type.strip()
|
||||
padding = ' ' * len(field_type)
|
||||
@@ -869,7 +869,7 @@ class GoogleDocstring:
|
||||
if not hasattr(self, "_annotations"):
|
||||
localns = getattr(self._config, "autodoc_type_aliases", {})
|
||||
localns.update(getattr(
|
||||
self._config, "napoleon_type_aliases", {}
|
||||
self._config, "napoleon_type_aliases", {},
|
||||
) or {})
|
||||
self._annotations = get_type_hints(self._obj, None, localns)
|
||||
if _name in self._annotations:
|
||||
@@ -1016,7 +1016,7 @@ def _token_type(token: str, location: str | None = None) -> str:
|
||||
|
||||
|
||||
def _convert_numpy_type_spec(
|
||||
_type: str, location: str | None = None, translations: dict = {}
|
||||
_type: str, location: str | None = None, translations: dict = {},
|
||||
) -> str:
|
||||
def convert_obj(obj, translations, default_translation):
|
||||
translation = translations.get(obj, obj)
|
||||
@@ -1154,7 +1154,7 @@ class NumpyDocstring(GoogleDocstring):
|
||||
what: str = '',
|
||||
name: str = '',
|
||||
obj: Any = None,
|
||||
options: Any = None
|
||||
options: Any = None,
|
||||
) -> None:
|
||||
self._directive_sections = ['.. index::']
|
||||
super().__init__(docstring, config, app, what, name, obj, options)
|
||||
@@ -1181,7 +1181,7 @@ class NumpyDocstring(GoogleDocstring):
|
||||
else:
|
||||
return func(name)
|
||||
|
||||
def _consume_field(self, parse_type: bool = True, prefer_type: bool = False
|
||||
def _consume_field(self, parse_type: bool = True, prefer_type: bool = False,
|
||||
) -> tuple[str, str, list[str]]:
|
||||
line = self._lines.next()
|
||||
if parse_type:
|
||||
@@ -1209,7 +1209,7 @@ class NumpyDocstring(GoogleDocstring):
|
||||
_desc = self.__class__(_desc, self._config).lines()
|
||||
return _name, _type, _desc
|
||||
|
||||
def _consume_returns_section(self, preprocess_types: bool = False
|
||||
def _consume_returns_section(self, preprocess_types: bool = False,
|
||||
) -> list[tuple[str, str, list[str]]]:
|
||||
return self._consume_fields(prefer_type=True)
|
||||
|
||||
|
||||
@@ -239,5 +239,5 @@ def setup(app: Sphinx) -> dict[str, Any]:
|
||||
return {
|
||||
'version': sphinx.__display_version__,
|
||||
'env_version': 2,
|
||||
'parallel_read_safe': True
|
||||
'parallel_read_safe': True,
|
||||
}
|
||||
|
||||
@@ -336,5 +336,5 @@ def setup(app: Sphinx) -> dict[str, Any]:
|
||||
return {
|
||||
'version': sphinx.__display_version__,
|
||||
'env_version': 1,
|
||||
'parallel_read_safe': True
|
||||
'parallel_read_safe': True,
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ def create_publisher(app: Sphinx, filetype: str) -> Publisher:
|
||||
parser=parser,
|
||||
writer=SphinxDummyWriter(),
|
||||
source_class=SphinxFileInput,
|
||||
destination=NullOutput()
|
||||
destination=NullOutput(),
|
||||
)
|
||||
# Propagate exceptions by default when used programmatically:
|
||||
defaults = {"traceback": True, **app.env.settings}
|
||||
|
||||
@@ -148,7 +148,7 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
|
||||
self,
|
||||
builder: Builder,
|
||||
theme: Theme | None = None,
|
||||
dirs: list[str] | None = None
|
||||
dirs: list[str] | None = None,
|
||||
) -> None:
|
||||
# create a chain of paths to search
|
||||
if theme:
|
||||
|
||||
@@ -77,7 +77,7 @@ class ModuleAnalyzer:
|
||||
return filename, None
|
||||
|
||||
@classmethod
|
||||
def for_string(cls, string: str, modname: str, srcname: str = '<string>'
|
||||
def for_string(cls, string: str, modname: str, srcname: str = '<string>',
|
||||
) -> ModuleAnalyzer:
|
||||
return cls(string, modname, srcname)
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ def parse(code: str, mode: str = 'exec') -> ast.AST:
|
||||
"""Parse the *code* using the built-in ast module."""
|
||||
warnings.warn(
|
||||
"'sphinx.pycode.ast.parse' is deprecated, use 'ast.parse' instead.",
|
||||
RemovedInSphinx70Warning, stacklevel=2
|
||||
RemovedInSphinx70Warning, stacklevel=2,
|
||||
)
|
||||
try:
|
||||
return ast.parse(code, mode=mode, type_comments=True)
|
||||
|
||||
@@ -349,7 +349,7 @@ class VariableCommentPicker(ast.NodeVisitor):
|
||||
try:
|
||||
targets = get_assign_targets(node)
|
||||
varnames: list[str] = sum(
|
||||
[get_lvar_names(t, self=self.get_self()) for t in targets], []
|
||||
[get_lvar_names(t, self=self.get_self()) for t in targets], [],
|
||||
)
|
||||
current_line = self.get_line(node.lineno)
|
||||
except TypeError:
|
||||
|
||||
@@ -92,5 +92,5 @@ class PyramidStyle(Style):
|
||||
Generic.Output: "#888",
|
||||
Generic.Traceback: "#04D",
|
||||
|
||||
Error: "#a40000 bg:#fbe3e4"
|
||||
Error: "#a40000 bg:#fbe3e4",
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ logger = logging.getLogger(__name__)
|
||||
# list of deprecated extensions. Keys are extension name.
|
||||
# Values are Sphinx version that merge the extension.
|
||||
EXTENSION_BLACKLIST = {
|
||||
"sphinxjp.themecore": "1.2"
|
||||
"sphinxjp.themecore": "1.2",
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ class SphinxComponentRegistry:
|
||||
directives[name] = cls
|
||||
|
||||
def add_role_to_domain(self, domain: str, name: str,
|
||||
role: RoleFunction | XRefRole, override: bool = False
|
||||
role: RoleFunction | XRefRole, override: bool = False,
|
||||
) -> None:
|
||||
logger.debug('[app] adding role to domain: %r', (domain, name, role))
|
||||
if domain not in self.domains:
|
||||
@@ -234,7 +234,7 @@ class SphinxComponentRegistry:
|
||||
ref_nodeclass: type[TextElement] | None = None,
|
||||
objname: str = '',
|
||||
doc_field_types: list = [],
|
||||
override: bool = False
|
||||
override: bool = False,
|
||||
) -> None:
|
||||
logger.debug('[app] adding object type: %r',
|
||||
(directivename, rolename, indextemplate, parse_node,
|
||||
@@ -263,7 +263,7 @@ class SphinxComponentRegistry:
|
||||
indextemplate: str = '',
|
||||
ref_nodeclass: type[TextElement] | None = None,
|
||||
objname: str = '',
|
||||
override: bool = False
|
||||
override: bool = False,
|
||||
) -> None:
|
||||
logger.debug('[app] adding crossref type: %r',
|
||||
(directivename, rolename, indextemplate, ref_nodeclass, objname))
|
||||
@@ -334,7 +334,7 @@ class SphinxComponentRegistry:
|
||||
except ValueError as exc:
|
||||
raise ExtensionError(
|
||||
__('kwargs for add_node() must be a (visit, depart) '
|
||||
'function tuple: %r=%r') % (builder_name, handlers)
|
||||
'function tuple: %r=%r') % (builder_name, handlers),
|
||||
) from exc
|
||||
|
||||
def get_translator_class(self, builder: Builder) -> type[nodes.NodeVisitor]:
|
||||
@@ -405,7 +405,7 @@ class SphinxComponentRegistry:
|
||||
self,
|
||||
node: type[Node],
|
||||
figtype: str,
|
||||
title_getter: TitleGetter | None = None, override: bool = False
|
||||
title_getter: TitleGetter | None = None, override: bool = False,
|
||||
) -> None:
|
||||
logger.debug('[app] adding enumerable node: (%r, %r, %r)', node, figtype, title_getter)
|
||||
if node in self.enumerable_nodes and not override:
|
||||
@@ -459,7 +459,7 @@ class SphinxComponentRegistry:
|
||||
raise VersionRequirementError(
|
||||
__('The %s extension used by this project needs at least '
|
||||
'Sphinx v%s; it therefore cannot be built with this '
|
||||
'version.') % (extname, err)
|
||||
'version.') % (extname, err),
|
||||
) from err
|
||||
|
||||
if metadata is None:
|
||||
|
||||
@@ -365,7 +365,7 @@ class Abbreviation(SphinxRole):
|
||||
# TODO: Change to use `SphinxRole` once SphinxRole is fixed to support options.
|
||||
def code_role(name: str, rawtext: str, text: str, lineno: int,
|
||||
inliner: docutils.parsers.rst.states.Inliner,
|
||||
options: dict = {}, content: list[str] = []
|
||||
options: dict = {}, content: list[str] = [],
|
||||
) -> tuple[list[Node], list[system_message]]:
|
||||
options = options.copy()
|
||||
docutils.parsers.rst.roles.set_classes(options)
|
||||
|
||||
@@ -109,7 +109,7 @@ class SphinxTestApp(application.Sphinx):
|
||||
warning: IO | None = None,
|
||||
tags: list[str] | None = None,
|
||||
docutilsconf: str | None = None,
|
||||
parallel: int = 0
|
||||
parallel: int = 0,
|
||||
) -> None:
|
||||
|
||||
if docutilsconf is not None:
|
||||
|
||||
@@ -390,7 +390,7 @@ class GlossarySorter(SphinxTransform):
|
||||
definition_list,
|
||||
key=lambda item: unicodedata.normalize(
|
||||
'NFD',
|
||||
cast(nodes.term, item)[0].astext().lower())
|
||||
cast(nodes.term, item)[0].astext().lower()),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ class Locale(SphinxTransform):
|
||||
# ignore unexpected markups in translation message
|
||||
unexpected: tuple[type[Element], ...] = (
|
||||
nodes.paragraph, # expected form of translation
|
||||
nodes.title # generated by above "Subelements phase2"
|
||||
nodes.title, # generated by above "Subelements phase2"
|
||||
)
|
||||
|
||||
# following types are expected if
|
||||
@@ -319,10 +319,10 @@ class Locale(SphinxTransform):
|
||||
|
||||
is_autofootnote_ref = NodeMatcher(nodes.footnote_reference, auto=Any)
|
||||
old_foot_refs: list[nodes.footnote_reference] = list(
|
||||
node.findall(is_autofootnote_ref)
|
||||
node.findall(is_autofootnote_ref),
|
||||
)
|
||||
new_foot_refs: list[nodes.footnote_reference] = list(
|
||||
patch.findall(is_autofootnote_ref)
|
||||
patch.findall(is_autofootnote_ref),
|
||||
)
|
||||
if not noqa and len(old_foot_refs) != len(new_foot_refs):
|
||||
old_foot_ref_rawsources = [ref.rawsource for ref in old_foot_refs]
|
||||
@@ -413,7 +413,7 @@ class Locale(SphinxTransform):
|
||||
is_citation_ref = NodeMatcher(nodes.citation_reference, refname=Any)
|
||||
old_cite_refs: list[nodes.citation_reference] = list(node.findall(is_citation_ref))
|
||||
new_cite_refs: list[nodes.citation_reference] = list(
|
||||
patch.findall(is_citation_ref)
|
||||
patch.findall(is_citation_ref),
|
||||
)
|
||||
refname_ids_map = {}
|
||||
if not noqa and len(old_cite_refs) != len(new_cite_refs):
|
||||
|
||||
@@ -115,7 +115,7 @@ class ReferencesResolver(SphinxPostTransform):
|
||||
node.replace_self(newnodes)
|
||||
|
||||
def resolve_anyref(
|
||||
self, refdoc: str, node: pending_xref, contnode: Element
|
||||
self, refdoc: str, node: pending_xref, contnode: Element,
|
||||
) -> Element | None:
|
||||
"""Resolve reference generated by the "any" role."""
|
||||
stddomain = self.env.get_domain('std')
|
||||
@@ -208,7 +208,7 @@ class ReferencesResolver(SphinxPostTransform):
|
||||
msg = __('%r reference target not found: %s') % (typ, target)
|
||||
logger.warning(msg, location=node, type='ref', subtype=typ)
|
||||
|
||||
def find_pending_xref_condition(self, node: pending_xref, conditions: Sequence[str]
|
||||
def find_pending_xref_condition(self, node: pending_xref, conditions: Sequence[str],
|
||||
) -> list[Node] | None:
|
||||
for condition in conditions:
|
||||
matched = find_pending_xref_condition(node, condition)
|
||||
|
||||
@@ -295,7 +295,7 @@ class DocFieldTransformer:
|
||||
self.directive.domain,
|
||||
target,
|
||||
contnode=content[0],
|
||||
env=self.directive.state.document.settings.env
|
||||
env=self.directive.state.document.settings.env,
|
||||
)
|
||||
if _is_single_paragraph(field_body):
|
||||
paragraph = cast(nodes.paragraph, field_body[0])
|
||||
|
||||
@@ -253,7 +253,7 @@ class CustomReSTDispatcher:
|
||||
self.enable()
|
||||
|
||||
def __exit__(
|
||||
self, exc_type: type[Exception], exc_value: Exception, traceback: Any
|
||||
self, exc_type: type[Exception], exc_value: Exception, traceback: Any,
|
||||
) -> None:
|
||||
self.disable()
|
||||
|
||||
@@ -269,12 +269,13 @@ class CustomReSTDispatcher:
|
||||
roles.role = self.role_func
|
||||
|
||||
def directive(self,
|
||||
directive_name: str, language_module: ModuleType, document: nodes.document
|
||||
directive_name: str, language_module: ModuleType, document: nodes.document,
|
||||
) -> tuple[type[Directive] | None, list[system_message]]:
|
||||
return self.directive_func(directive_name, language_module, document)
|
||||
|
||||
def role(self, role_name: str, language_module: ModuleType, lineno: int, reporter: Reporter
|
||||
) -> tuple[RoleFunction, list[system_message]]:
|
||||
def role(
|
||||
self, role_name: str, language_module: ModuleType, lineno: int, reporter: Reporter,
|
||||
) -> tuple[RoleFunction, list[system_message]]:
|
||||
return self.role_func(role_name, language_module, lineno, reporter)
|
||||
|
||||
|
||||
@@ -321,15 +322,16 @@ class sphinx_domains(CustomReSTDispatcher):
|
||||
raise ElementLookupError
|
||||
|
||||
def directive(self,
|
||||
directive_name: str, language_module: ModuleType, document: nodes.document
|
||||
directive_name: str, language_module: ModuleType, document: nodes.document,
|
||||
) -> tuple[type[Directive] | None, list[system_message]]:
|
||||
try:
|
||||
return self.lookup_domain_element('directive', directive_name)
|
||||
except ElementLookupError:
|
||||
return super().directive(directive_name, language_module, document)
|
||||
|
||||
def role(self, role_name: str, language_module: ModuleType, lineno: int, reporter: Reporter
|
||||
) -> tuple[RoleFunction, list[system_message]]:
|
||||
def role(
|
||||
self, role_name: str, language_module: ModuleType, lineno: int, reporter: Reporter,
|
||||
) -> tuple[RoleFunction, list[system_message]]:
|
||||
try:
|
||||
return self.lookup_domain_element('role', role_name)
|
||||
except ElementLookupError:
|
||||
@@ -465,7 +467,7 @@ class SphinxRole:
|
||||
#: (from the "role" directive).
|
||||
|
||||
def __call__(self, name: str, rawtext: str, text: str, lineno: int,
|
||||
inliner: Inliner, options: dict = {}, content: list[str] = []
|
||||
inliner: Inliner, options: dict = {}, content: list[str] = [],
|
||||
) -> tuple[list[Node], list[system_message]]:
|
||||
self.rawtext = rawtext
|
||||
self.text = unescape(text)
|
||||
@@ -528,7 +530,7 @@ class ReferenceRole(SphinxRole):
|
||||
explicit_title_re = re.compile(r'^(.+?)\s*(?<!\x00)<(.*?)>$', re.DOTALL)
|
||||
|
||||
def __call__(self, name: str, rawtext: str, text: str, lineno: int,
|
||||
inliner: Inliner, options: dict = {}, content: list[str] = []
|
||||
inliner: Inliner, options: dict = {}, content: list[str] = [],
|
||||
) -> tuple[list[Node], list[system_message]]:
|
||||
# if the first character is a bang, don't cross-reference at all
|
||||
self.disabled = text.startswith('!')
|
||||
|
||||
@@ -193,7 +193,7 @@ def babel_format_date(date: datetime, format: str, locale: str,
|
||||
|
||||
|
||||
def format_date(
|
||||
format: str, date: datetime | None = None, language: str | None = None
|
||||
format: str, date: datetime | None = None, language: str | None = None,
|
||||
) -> str:
|
||||
if date is None:
|
||||
# If time is not specified, try to use $SOURCE_DATE_EPOCH variable
|
||||
|
||||
@@ -23,7 +23,7 @@ mime_suffixes = {
|
||||
'.pdf': 'application/pdf',
|
||||
'.svg': 'image/svg+xml',
|
||||
'.svgz': 'image/svg+xml',
|
||||
'.ai': 'application/illustrator'
|
||||
'.ai': 'application/illustrator',
|
||||
}
|
||||
_suffix_from_mime = {v: k for k, v in reversed(mime_suffixes.items())}
|
||||
|
||||
|
||||
@@ -522,7 +522,7 @@ def _should_unwrap(subject: Callable) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def signature(subject: Callable, bound_method: bool = False, type_aliases: dict = {}
|
||||
def signature(subject: Callable, bound_method: bool = False, type_aliases: dict = {},
|
||||
) -> inspect.Signature:
|
||||
"""Return a Signature object for the given *subject*.
|
||||
|
||||
@@ -579,7 +579,7 @@ def signature(subject: Callable, bound_method: bool = False, type_aliases: dict
|
||||
|
||||
|
||||
def evaluate_signature(sig: inspect.Signature, globalns: dict | None = None,
|
||||
localns: dict | None = None
|
||||
localns: dict | None = None,
|
||||
) -> inspect.Signature:
|
||||
"""Evaluate unresolved type annotations in a signature object."""
|
||||
def evaluate_forwardref(ref: ForwardRef, globalns: dict, localns: dict) -> Any:
|
||||
@@ -728,7 +728,7 @@ def signature_from_ast(node: ast.FunctionDef, code: str = '') -> inspect.Signatu
|
||||
default = Parameter.empty
|
||||
else:
|
||||
default = DefaultValue(
|
||||
ast_unparse(defaults[i + posonlyargs], code) # type: ignore
|
||||
ast_unparse(defaults[i + posonlyargs], code), # type: ignore
|
||||
)
|
||||
|
||||
annotation = ast_unparse(arg.annotation, code) or Parameter.empty
|
||||
@@ -764,7 +764,7 @@ def getdoc(
|
||||
attrgetter: Callable = safe_getattr,
|
||||
allow_inherited: bool = False,
|
||||
cls: Any = None,
|
||||
name: str | None = None
|
||||
name: str | None = None,
|
||||
) -> str | None:
|
||||
"""Get the docstring for the object.
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ def dumps(obj: Any, key: bool = False) -> str:
|
||||
return str(obj)
|
||||
elif isinstance(obj, dict):
|
||||
return '{%s}' % ','.join(
|
||||
sorted(f'{dumps(key, True)}:{dumps(value)}' for key, value in obj.items())
|
||||
sorted(f'{dumps(key, True)}:{dumps(value)}' for key, value in obj.items()),
|
||||
)
|
||||
elif isinstance(obj, set):
|
||||
return '[%s]' % ','.join(sorted(dumps(x) for x in obj))
|
||||
|
||||
@@ -45,7 +45,7 @@ COLOR_MAP = defaultdict(lambda: 'blue',
|
||||
{
|
||||
logging.ERROR: 'darkred',
|
||||
logging.WARNING: 'red',
|
||||
logging.DEBUG: 'darkgray'
|
||||
logging.DEBUG: 'darkgray',
|
||||
})
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ class SphinxLoggerAdapter(logging.LoggerAdapter):
|
||||
KEYWORDS = ['type', 'subtype', 'location', 'nonl', 'color', 'once']
|
||||
|
||||
def log( # type: ignore[override]
|
||||
self, level: int | str, msg: str, *args: Any, **kwargs: Any
|
||||
self, level: int | str, msg: str, *args: Any, **kwargs: Any,
|
||||
) -> None:
|
||||
if isinstance(level, int):
|
||||
super().log(level, msg, *args, **kwargs)
|
||||
|
||||
@@ -299,7 +299,7 @@ def get_prev_node(node: Node) -> Node | None:
|
||||
|
||||
|
||||
def traverse_translatable_index(
|
||||
doctree: Element
|
||||
doctree: Element,
|
||||
) -> Iterable[tuple[Element, list[IndexEntry]]]:
|
||||
"""Traverse translatable index node from a document tree."""
|
||||
matcher = NodeMatcher(addnodes.index, inline=False)
|
||||
@@ -354,7 +354,7 @@ indextypes = [
|
||||
]
|
||||
|
||||
|
||||
def process_index_entry(entry: str, targetid: str
|
||||
def process_index_entry(entry: str, targetid: str,
|
||||
) -> list[tuple[str, str, str, str, str | None]]:
|
||||
from sphinx.domains.python import pairindextypes
|
||||
|
||||
@@ -394,7 +394,7 @@ def process_index_entry(entry: str, targetid: str
|
||||
|
||||
|
||||
def inline_all_toctrees(builder: Builder, docnameset: set[str], docname: str,
|
||||
tree: nodes.document, colorfunc: Callable, traversed: list[str]
|
||||
tree: nodes.document, colorfunc: Callable, traversed: list[str],
|
||||
) -> nodes.document:
|
||||
"""Inline all toctrees in the *tree*.
|
||||
|
||||
@@ -526,7 +526,7 @@ def make_id(env: BuildEnvironment, document: nodes.document,
|
||||
return node_id
|
||||
|
||||
|
||||
def find_pending_xref_condition(node: addnodes.pending_xref, condition: str
|
||||
def find_pending_xref_condition(node: addnodes.pending_xref, condition: str,
|
||||
) -> Element | None:
|
||||
"""Pick matched pending_xref_condition node up from the pending_xref."""
|
||||
for subnode in node:
|
||||
@@ -537,7 +537,7 @@ def find_pending_xref_condition(node: addnodes.pending_xref, condition: str
|
||||
|
||||
|
||||
def make_refnode(builder: Builder, fromdocname: str, todocname: str, targetid: str | None,
|
||||
child: Node | list[Node], title: str | None = None
|
||||
child: Node | list[Node], title: str | None = None,
|
||||
) -> nodes.reference:
|
||||
"""Shortcut to create a reference node."""
|
||||
node = nodes.reference('', '', internal=True)
|
||||
|
||||
@@ -200,7 +200,7 @@ class FileAvoidWrite:
|
||||
return self
|
||||
|
||||
def __exit__(
|
||||
self, exc_type: type[Exception], exc_value: Exception, traceback: Any
|
||||
self, exc_type: type[Exception], exc_value: Exception, traceback: Any,
|
||||
) -> bool:
|
||||
self.close()
|
||||
return True
|
||||
|
||||
@@ -30,7 +30,7 @@ class SerialTasks:
|
||||
pass
|
||||
|
||||
def add_task(
|
||||
self, task_func: Callable, arg: Any = None, result_func: Callable | None = None
|
||||
self, task_func: Callable, arg: Any = None, result_func: Callable | None = None,
|
||||
) -> None:
|
||||
if arg is not None:
|
||||
res = task_func(arg)
|
||||
@@ -80,7 +80,7 @@ class ParallelTasks:
|
||||
pipe.send((failed, collector.logs, ret))
|
||||
|
||||
def add_task(
|
||||
self, task_func: Callable, arg: Any = None, result_func: Callable | None = None
|
||||
self, task_func: Callable, arg: Any = None, result_func: Callable | None = None,
|
||||
) -> None:
|
||||
tid = self._taskid
|
||||
self._taskid += 1
|
||||
|
||||
@@ -62,7 +62,7 @@ class SphinxRenderer(FileRenderer):
|
||||
|
||||
class LaTeXRenderer(SphinxRenderer):
|
||||
def __init__(
|
||||
self, template_path: str | None = None, latex_engine: str | None = None
|
||||
self, template_path: str | None = None, latex_engine: str | None = None,
|
||||
) -> None:
|
||||
if template_path is None:
|
||||
template_path = os.path.join(package_dir, 'templates', 'latex')
|
||||
@@ -86,7 +86,7 @@ class LaTeXRenderer(SphinxRenderer):
|
||||
|
||||
class ReSTRenderer(SphinxRenderer):
|
||||
def __init__(
|
||||
self, template_path: None | str | list[str] = None, language: str | None = None
|
||||
self, template_path: None | str | list[str] = None, language: str | None = None,
|
||||
) -> None:
|
||||
super().__init__(template_path)
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ Inventory = Dict[str, Dict[str, InventoryItem]]
|
||||
|
||||
|
||||
def get_type_hints(
|
||||
obj: Any, globalns: dict[str, Any] | None = None, localns: dict | None = None
|
||||
obj: Any, globalns: dict[str, Any] | None = None, localns: dict | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Return a dictionary containing type hints for a function, method, module or class
|
||||
object.
|
||||
@@ -299,7 +299,7 @@ def stringify_annotation(
|
||||
qualname = annotation_qualname
|
||||
else:
|
||||
qualname = stringify_annotation(
|
||||
annotation.__origin__, 'fully-qualified-except-typing'
|
||||
annotation.__origin__, 'fully-qualified-except-typing',
|
||||
).replace('typing.', '') # ex. Union
|
||||
elif annotation_qualname:
|
||||
qualname = annotation_qualname
|
||||
|
||||
@@ -429,7 +429,7 @@ class HTML4Translator(SphinxTranslator, BaseTranslator):
|
||||
|
||||
highlighted = self.highlighter.highlight_block(
|
||||
node.rawsource, lang, opts=opts, linenos=linenos,
|
||||
location=node, **highlight_args
|
||||
location=node, **highlight_args,
|
||||
)
|
||||
starttag = self.starttag(node, 'div', suffix='',
|
||||
CLASS='highlight-%s notranslate' % lang)
|
||||
|
||||
@@ -415,7 +415,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
|
||||
|
||||
highlighted = self.highlighter.highlight_block(
|
||||
node.rawsource, lang, opts=opts, linenos=linenos,
|
||||
location=node, **highlight_args
|
||||
location=node, **highlight_args,
|
||||
)
|
||||
starttag = self.starttag(node, 'div', suffix='',
|
||||
CLASS='highlight-%s notranslate' % lang)
|
||||
|
||||
@@ -198,7 +198,7 @@ class Table:
|
||||
self.cells[(self.row + row, self.col + col)] = self.cell_id
|
||||
|
||||
def cell(
|
||||
self, row: int | None = None, col: int | None = None
|
||||
self, row: int | None = None, col: int | None = None,
|
||||
) -> TableCell | None:
|
||||
"""Returns a cell object (i.e. rectangular area) containing given position.
|
||||
|
||||
@@ -433,7 +433,7 @@ class LaTeXTranslator(SphinxTranslator):
|
||||
def astext(self) -> str:
|
||||
self.elements.update({
|
||||
'body': ''.join(self.body),
|
||||
'indices': self.generate_indices()
|
||||
'indices': self.generate_indices(),
|
||||
})
|
||||
return self.render('latex.tex_t', self.elements)
|
||||
|
||||
@@ -1824,7 +1824,7 @@ class LaTeXTranslator(SphinxTranslator):
|
||||
|
||||
hlcode = self.highlighter.highlight_block(
|
||||
node.rawsource, lang, opts=opts, linenos=linenos,
|
||||
location=node, **highlight_args
|
||||
location=node, **highlight_args,
|
||||
)
|
||||
if self.in_footnote:
|
||||
self.body.append(CR + r'\sphinxSetupCodeBlockInFootnote')
|
||||
|
||||
@@ -221,7 +221,7 @@ class TexinfoTranslator(SphinxTranslator):
|
||||
'copyright': self.escape(self.config.copyright),
|
||||
'date': self.escape(self.config.today or
|
||||
format_date(self.config.today_fmt or _('%b %d, %Y'),
|
||||
language=self.config.language))
|
||||
language=self.config.language)),
|
||||
})
|
||||
# title
|
||||
title: str = self.settings.title
|
||||
@@ -495,7 +495,7 @@ class TexinfoTranslator(SphinxTranslator):
|
||||
# TODO: move this to sphinx.util
|
||||
|
||||
def collect_footnotes(
|
||||
self, node: Element
|
||||
self, node: Element,
|
||||
) -> dict[str, list[collected_footnote | bool]]:
|
||||
def footnotes_under(n: Element) -> Iterator[nodes.footnote]:
|
||||
if isinstance(n, nodes.footnote):
|
||||
|
||||
@@ -233,8 +233,8 @@ class Table:
|
||||
linestr.append(
|
||||
" " +
|
||||
physical_text.ljust(
|
||||
self.cell_width(cell, self.measured_widths) + 1 + adjust_len
|
||||
) + "|"
|
||||
self.cell_width(cell, self.measured_widths) + 1 + adjust_len,
|
||||
) + "|",
|
||||
)
|
||||
out.append("".join(linestr))
|
||||
out.append(writesep("-"))
|
||||
@@ -759,7 +759,7 @@ class TextTranslator(SphinxTranslator):
|
||||
|
||||
def visit_entry(self, node: Element) -> None:
|
||||
self.entry = Cell(
|
||||
rowspan=node.get("morerows", 0) + 1, colspan=node.get("morecols", 0) + 1
|
||||
rowspan=node.get("morerows", 0) + 1, colspan=node.get("morecols", 0) + 1,
|
||||
)
|
||||
self.new_state(0)
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ def test_instantiation(tmp_path_factory, rootdir: str, monkeypatch):
|
||||
app_ = SphinxTestApp(
|
||||
srcdir=path(src_dir),
|
||||
status=StringIO(),
|
||||
warning=StringIO()
|
||||
warning=StringIO(),
|
||||
)
|
||||
sys.path[:] = syspath
|
||||
app_.cleanup()
|
||||
|
||||
@@ -28,7 +28,7 @@ class EPUBElementTree:
|
||||
'ibooks': 'http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/',
|
||||
'ncx': 'http://www.daisy.org/z3986/2005/ncx/',
|
||||
'xhtml': 'http://www.w3.org/1999/xhtml',
|
||||
'epub': 'http://www.idpf.org/2007/ops'
|
||||
'epub': 'http://www.idpf.org/2007/ops',
|
||||
}
|
||||
|
||||
def __init__(self, tree):
|
||||
|
||||
@@ -60,7 +60,7 @@ def flat_dict(d):
|
||||
[
|
||||
zip(cycle([fname]), values)
|
||||
for fname, values in d.items()
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -396,7 +396,7 @@ def test_html4_deprecation(make_app, tempdir):
|
||||
'otherext.html': [
|
||||
(".//h1", "Generated section"),
|
||||
(".//a[@href='_sources/otherext.foo.txt']", ''),
|
||||
]
|
||||
],
|
||||
}))
|
||||
@pytest.mark.sphinx('html', tags=['testtag'],
|
||||
confoverrides={'html_context.hckey_co': 'hcval_co'})
|
||||
@@ -1434,7 +1434,7 @@ def test_html_sidebar(app, status, warning):
|
||||
@pytest.mark.parametrize('fname,expect', flat_dict({
|
||||
'index.html': [(".//em/a[@href='https://example.com/man.1']", "", True),
|
||||
(".//em/a[@href='https://example.com/ls.1']", "", True),
|
||||
(".//em/a[@href='https://example.com/sphinx.']", "", True)]
|
||||
(".//em/a[@href='https://example.com/sphinx.']", "", True)],
|
||||
|
||||
}))
|
||||
@pytest.mark.sphinx('html', testroot='manpage_url', confoverrides={
|
||||
|
||||
@@ -178,7 +178,7 @@ def test_latex_basic(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='basic',
|
||||
confoverrides={
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'manual')]
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'manual')],
|
||||
})
|
||||
def test_latex_basic_manual(app, status, warning):
|
||||
app.builder.build_all()
|
||||
@@ -190,7 +190,7 @@ def test_latex_basic_manual(app, status, warning):
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='basic',
|
||||
confoverrides={
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'howto')]
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'howto')],
|
||||
})
|
||||
def test_latex_basic_howto(app, status, warning):
|
||||
app.builder.build_all()
|
||||
@@ -203,7 +203,7 @@ def test_latex_basic_howto(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='basic',
|
||||
confoverrides={
|
||||
'language': 'ja',
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'manual')]
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'manual')],
|
||||
})
|
||||
def test_latex_basic_manual_ja(app, status, warning):
|
||||
app.builder.build_all()
|
||||
@@ -216,7 +216,7 @@ def test_latex_basic_manual_ja(app, status, warning):
|
||||
@pytest.mark.sphinx('latex', testroot='basic',
|
||||
confoverrides={
|
||||
'language': 'ja',
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'howto')]
|
||||
'latex_documents': [('index', 'test.tex', 'title', 'author', 'howto')],
|
||||
})
|
||||
def test_latex_basic_howto_ja(app, status, warning):
|
||||
app.builder.build_all()
|
||||
@@ -1119,7 +1119,7 @@ def test_latex_toplevel_sectioning_is_part(app, status, warning):
|
||||
confoverrides={'latex_toplevel_sectioning': 'part',
|
||||
'latex_documents': [
|
||||
('index', 'python.tex', 'Sphinx Tests Documentation',
|
||||
'Georg Brandl', 'howto')
|
||||
'Georg Brandl', 'howto'),
|
||||
]})
|
||||
def test_latex_toplevel_sectioning_is_part_with_howto(app, status, warning):
|
||||
app.builder.build_all()
|
||||
@@ -1149,7 +1149,7 @@ def test_latex_toplevel_sectioning_is_chapter(app, status, warning):
|
||||
confoverrides={'latex_toplevel_sectioning': 'chapter',
|
||||
'latex_documents': [
|
||||
('index', 'python.tex', 'Sphinx Tests Documentation',
|
||||
'Georg Brandl', 'howto')
|
||||
'Georg Brandl', 'howto'),
|
||||
]})
|
||||
def test_latex_toplevel_sectioning_is_chapter_with_howto(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import http.server
|
||||
import json
|
||||
import re
|
||||
@@ -13,7 +14,6 @@ from queue import Queue
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
from sphinx.builders.linkcheck import HyperlinkAvailabilityCheckWorker, RateLimit
|
||||
from sphinx.testing.util import strip_escseq
|
||||
@@ -70,7 +70,7 @@ def test_defaults_json(app):
|
||||
'status': 'working',
|
||||
'code': 0,
|
||||
'uri': 'https://www.google.com#!bar',
|
||||
'info': ''
|
||||
'info': '',
|
||||
}
|
||||
# looking for non-existent URL should fail
|
||||
dnerow = rowsby['https://localhost:7777/doesnotexist']
|
||||
@@ -85,7 +85,7 @@ def test_defaults_json(app):
|
||||
'status': 'broken',
|
||||
'code': 0,
|
||||
'uri': 'https://www.google.com/image2.png',
|
||||
'info': '404 Client Error: Not Found for url: https://www.google.com/image2.png'
|
||||
'info': '404 Client Error: Not Found for url: https://www.google.com/image2.png',
|
||||
}
|
||||
# looking for '#top' and '#does-not-exist' not found should fail
|
||||
assert rowsby["https://www.google.com/#top"]["info"] == "Anchor 'top' not found"
|
||||
@@ -100,7 +100,7 @@ def test_defaults_json(app):
|
||||
'status': 'redirected',
|
||||
'code': 302,
|
||||
'uri': 'https://www.sphinx-doc.org/',
|
||||
'info': 'https://www.sphinx-doc.org/en/master/'
|
||||
'info': 'https://www.sphinx-doc.org/en/master/',
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ def test_defaults_json(app):
|
||||
'https://www.sphinx-doc.org/',
|
||||
'https://www.google.com/image.png',
|
||||
'https://www.google.com/image2.png',
|
||||
'path/to/notfound']
|
||||
'path/to/notfound'],
|
||||
})
|
||||
def test_anchors_ignored(app):
|
||||
app.build()
|
||||
@@ -162,8 +162,8 @@ def test_auth_header_uses_first_match(app, capsys):
|
||||
with http_server(HeadersDumperHandler):
|
||||
app.build()
|
||||
stdout, stderr = capsys.readouterr()
|
||||
auth = requests.auth._basic_auth_str('user1', 'password')
|
||||
assert "Authorization: %s\n" % auth in stdout
|
||||
encoded_auth = base64.b64encode(b'user1:password').decode('ascii')
|
||||
assert f"Authorization: Basic {encoded_auth}\n" in stdout
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
@@ -184,7 +184,7 @@ def test_auth_header_no_match(app, capsys):
|
||||
},
|
||||
"*": {
|
||||
"X-Secret": "open sesami",
|
||||
}
|
||||
},
|
||||
}})
|
||||
def test_linkcheck_request_headers(app, capsys):
|
||||
with http_server(HeadersDumperHandler):
|
||||
@@ -200,7 +200,7 @@ def test_linkcheck_request_headers(app, capsys):
|
||||
'linkcheck', testroot='linkcheck-localserver', freshenv=True,
|
||||
confoverrides={'linkcheck_request_headers': {
|
||||
"http://localhost:7777": {"Accept": "application/json"},
|
||||
"*": {"X-Secret": "open sesami"}
|
||||
"*": {"X-Secret": "open sesami"},
|
||||
}})
|
||||
def test_linkcheck_request_headers_no_slash(app, capsys):
|
||||
with http_server(HeadersDumperHandler):
|
||||
@@ -216,7 +216,7 @@ def test_linkcheck_request_headers_no_slash(app, capsys):
|
||||
'linkcheck', testroot='linkcheck-localserver', freshenv=True,
|
||||
confoverrides={'linkcheck_request_headers': {
|
||||
"http://do.not.match.org": {"Accept": "application/json"},
|
||||
"*": {"X-Secret": "open sesami"}
|
||||
"*": {"X-Secret": "open sesami"},
|
||||
}})
|
||||
def test_linkcheck_request_headers_default(app, capsys):
|
||||
with http_server(HeadersDumperHandler):
|
||||
@@ -265,7 +265,7 @@ def test_follows_redirects_on_HEAD(app, capsys, warning):
|
||||
"""\
|
||||
127.0.0.1 - - [] "HEAD / HTTP/1.1" 302 -
|
||||
127.0.0.1 - - [] "HEAD /?redirected=1 HTTP/1.1" 204 -
|
||||
"""
|
||||
""",
|
||||
)
|
||||
assert warning.getvalue() == ''
|
||||
|
||||
@@ -285,14 +285,14 @@ def test_follows_redirects_on_GET(app, capsys, warning):
|
||||
127.0.0.1 - - [] "HEAD / HTTP/1.1" 405 -
|
||||
127.0.0.1 - - [] "GET / HTTP/1.1" 302 -
|
||||
127.0.0.1 - - [] "GET /?redirected=1 HTTP/1.1" 204 -
|
||||
"""
|
||||
""",
|
||||
)
|
||||
assert warning.getvalue() == ''
|
||||
|
||||
|
||||
@pytest.mark.sphinx('linkcheck', testroot='linkcheck-localserver-warn-redirects',
|
||||
freshenv=True, confoverrides={
|
||||
'linkcheck_allowed_redirects': {'http://localhost:7777/.*1': '.*'}
|
||||
'linkcheck_allowed_redirects': {'http://localhost:7777/.*1': '.*'},
|
||||
})
|
||||
def test_linkcheck_allowed_redirects(app, warning):
|
||||
with http_server(make_redirect_handler(support_head=False)):
|
||||
@@ -488,7 +488,7 @@ def test_too_many_requests_retry_after_int_delay(app, capsys, status):
|
||||
"""\
|
||||
127.0.0.1 - - [] "HEAD / HTTP/1.1" 429 -
|
||||
127.0.0.1 - - [] "HEAD / HTTP/1.1" 200 -
|
||||
"""
|
||||
""",
|
||||
)
|
||||
|
||||
|
||||
@@ -512,7 +512,7 @@ def test_too_many_requests_retry_after_HTTP_date(app, capsys):
|
||||
"""\
|
||||
127.0.0.1 - - [] "HEAD / HTTP/1.1" 429 -
|
||||
127.0.0.1 - - [] "HEAD / HTTP/1.1" 200 -
|
||||
"""
|
||||
""",
|
||||
)
|
||||
|
||||
|
||||
@@ -535,7 +535,7 @@ def test_too_many_requests_retry_after_without_header(app, capsys):
|
||||
"""\
|
||||
127.0.0.1 - - [] "HEAD / HTTP/1.1" 429 -
|
||||
127.0.0.1 - - [] "HEAD / HTTP/1.1" 200 -
|
||||
"""
|
||||
""",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ def test_nitpick_ignore(app, status, warning):
|
||||
'nitpick_ignore_regex': [
|
||||
(r'py:.*', r'.*postfix'),
|
||||
(r'.*:class', r'prefix.*'),
|
||||
]
|
||||
],
|
||||
})
|
||||
def test_nitpick_ignore_regex1(app, status, warning):
|
||||
app.builder.build_all()
|
||||
@@ -355,7 +355,7 @@ def test_nitpick_ignore_regex1(app, status, warning):
|
||||
'nitpick_ignore_regex': [
|
||||
(r'py:.*', r'prefix.*'),
|
||||
(r'.*:class', r'.*postfix'),
|
||||
]
|
||||
],
|
||||
})
|
||||
def test_nitpick_ignore_regex2(app, status, warning):
|
||||
app.builder.build_all()
|
||||
@@ -372,7 +372,7 @@ def test_nitpick_ignore_regex2(app, status, warning):
|
||||
(r'.*', r'prefix'),
|
||||
(r'.*', r'postfix'),
|
||||
(r'.*', r''),
|
||||
]
|
||||
],
|
||||
})
|
||||
def test_nitpick_ignore_regex_fullmatch(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
@@ -1212,7 +1212,7 @@ def test_domain_cpp_build_with_add_function_parentheses_is_True(app, status, war
|
||||
('', 'Sphinx::version'),
|
||||
('', 'version'),
|
||||
('', 'List'),
|
||||
('', 'MyEnum')
|
||||
('', 'MyEnum'),
|
||||
]
|
||||
parenPatterns = [
|
||||
('ref function without parens ', r'paren_1\(\)'),
|
||||
@@ -1222,7 +1222,7 @@ def test_domain_cpp_build_with_add_function_parentheses_is_True(app, status, war
|
||||
('ref op call without parens ', r'paren_5::operator\(\)\(\)'),
|
||||
('ref op call with parens ', r'paren_6::operator\(\)\(\)'),
|
||||
('ref op call without parens, explicit title ', 'paren_7_title'),
|
||||
('ref op call with parens, explicit title ', 'paren_8_title')
|
||||
('ref op call with parens, explicit title ', 'paren_8_title'),
|
||||
]
|
||||
|
||||
f = 'roles.html'
|
||||
@@ -1253,7 +1253,7 @@ def test_domain_cpp_build_with_add_function_parentheses_is_False(app, status, wa
|
||||
('', 'Sphinx::version'),
|
||||
('', 'version'),
|
||||
('', 'List'),
|
||||
('', 'MyEnum')
|
||||
('', 'MyEnum'),
|
||||
]
|
||||
parenPatterns = [
|
||||
('ref function without parens ', 'paren_1'),
|
||||
@@ -1263,7 +1263,7 @@ def test_domain_cpp_build_with_add_function_parentheses_is_False(app, status, wa
|
||||
('ref op call without parens ', r'paren_5::operator\(\)'),
|
||||
('ref op call with parens ', r'paren_6::operator\(\)'),
|
||||
('ref op call without parens, explicit title ', 'paren_7_title'),
|
||||
('ref op call with parens, explicit title ', 'paren_8_title')
|
||||
('ref op call with parens, explicit title ', 'paren_8_title'),
|
||||
]
|
||||
|
||||
f = 'roles.html'
|
||||
|
||||
@@ -597,7 +597,7 @@ def test_pydata_signature(app):
|
||||
desc_sig_space,
|
||||
[desc_sig_punctuation, '='],
|
||||
desc_sig_space,
|
||||
"1")]
|
||||
"1")],
|
||||
)],
|
||||
desc_content)]))
|
||||
assert_node(doctree[1], addnodes.desc, desctype="data",
|
||||
@@ -893,7 +893,7 @@ def test_pyattribute(app):
|
||||
[desc_annotation, (desc_sig_space,
|
||||
[desc_sig_punctuation, '='],
|
||||
desc_sig_space,
|
||||
"''")]
|
||||
"''")],
|
||||
)],
|
||||
[desc_content, ()]))
|
||||
assert_node(doctree[1][1][1][0][1][2], pending_xref, **{"py:class": "Class"})
|
||||
@@ -1346,7 +1346,7 @@ def test_module_index(app):
|
||||
IndexEntry('sphinx.builders.html', 2, 'index', 'module-sphinx.builders.html', '', '', ''),
|
||||
IndexEntry('sphinx.config', 2, 'index', 'module-sphinx.config', '', '', ''),
|
||||
IndexEntry('sphinx_intl', 0, 'index', 'module-sphinx_intl', '', '', '')])],
|
||||
False
|
||||
False,
|
||||
)
|
||||
|
||||
|
||||
@@ -1358,7 +1358,7 @@ def test_module_index_submodule(app):
|
||||
assert index.generate() == (
|
||||
[('s', [IndexEntry('sphinx', 1, '', '', '', '', ''),
|
||||
IndexEntry('sphinx.config', 2, 'index', 'module-sphinx.config', '', '', '')])],
|
||||
False
|
||||
False,
|
||||
)
|
||||
|
||||
|
||||
@@ -1371,7 +1371,7 @@ def test_module_index_not_collapsed(app):
|
||||
assert index.generate() == (
|
||||
[('d', [IndexEntry('docutils', 0, 'index', 'module-docutils', '', '', '')]),
|
||||
('s', [IndexEntry('sphinx', 0, 'index', 'module-sphinx', '', '', '')])],
|
||||
True
|
||||
True,
|
||||
)
|
||||
|
||||
|
||||
@@ -1392,7 +1392,7 @@ def test_modindex_common_prefix(app):
|
||||
('d', [IndexEntry('docutils', 0, 'index', 'module-docutils', '', '', '')]),
|
||||
('s', [IndexEntry('sphinx', 0, 'index', 'module-sphinx', '', '', ''),
|
||||
IndexEntry('sphinx_intl', 0, 'index', 'module-sphinx_intl', '', '', '')])],
|
||||
True
|
||||
True,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ def test_create_single_index(app):
|
||||
# ignored when getting the first letter.
|
||||
assert index[5] == ('\u05e2', [(
|
||||
'\N{RIGHT-TO-LEFT MARK}\u05e2\u05d1\u05e8\u05d9\u05ea\N{LEFT-TO-RIGHT MARK}',
|
||||
[[('', '#index-7')], [], None]
|
||||
[[('', '#index-7')], [], None],
|
||||
)])
|
||||
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@ def extract_toc(path):
|
||||
|
||||
@pytest.mark.apidoc(
|
||||
coderoot='test-apidoc-subpackage-in-toc',
|
||||
options=['--separate']
|
||||
options=['--separate'],
|
||||
)
|
||||
def test_subpackage_in_toc(make_app, apidoc):
|
||||
"""Make sure that empty subpackages with non-empty subpackages in them
|
||||
|
||||
@@ -532,7 +532,7 @@ def test_autodoc_attributes(app):
|
||||
' :synopsis: Synopsis',
|
||||
' :platform: Platform',
|
||||
' :deprecated:',
|
||||
''
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@@ -552,7 +552,7 @@ def test_autodoc_members(app):
|
||||
' .. py:attribute:: Base.inheritedattr',
|
||||
' .. py:method:: Base.inheritedclassmeth()',
|
||||
' .. py:method:: Base.inheritedmeth()',
|
||||
' .. py:method:: Base.inheritedstaticmeth(cls)'
|
||||
' .. py:method:: Base.inheritedstaticmeth(cls)',
|
||||
]
|
||||
|
||||
# default specific-members
|
||||
@@ -561,7 +561,7 @@ def test_autodoc_members(app):
|
||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||
'.. py:class:: Base()',
|
||||
' .. py:method:: Base.inheritedmeth()',
|
||||
' .. py:method:: Base.inheritedstaticmeth(cls)'
|
||||
' .. py:method:: Base.inheritedstaticmeth(cls)',
|
||||
]
|
||||
|
||||
# ALL-members override autodoc_default_options
|
||||
@@ -573,7 +573,7 @@ def test_autodoc_members(app):
|
||||
' .. py:attribute:: Base.inheritedattr',
|
||||
' .. py:method:: Base.inheritedclassmeth()',
|
||||
' .. py:method:: Base.inheritedmeth()',
|
||||
' .. py:method:: Base.inheritedstaticmeth(cls)'
|
||||
' .. py:method:: Base.inheritedstaticmeth(cls)',
|
||||
]
|
||||
|
||||
# members override autodoc_default_options
|
||||
@@ -592,7 +592,7 @@ def test_autodoc_members(app):
|
||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||
'.. py:class:: Base()',
|
||||
' .. py:method:: Base.inheritedmeth()',
|
||||
' .. py:method:: Base.inheritedstaticmeth(cls)'
|
||||
' .. py:method:: Base.inheritedstaticmeth(cls)',
|
||||
]
|
||||
|
||||
|
||||
@@ -604,7 +604,7 @@ def test_autodoc_exclude_members(app):
|
||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||
'.. py:class:: Base()',
|
||||
' .. py:attribute:: Base.inheritedattr',
|
||||
' .. py:method:: Base.inheritedclassmeth()'
|
||||
' .. py:method:: Base.inheritedclassmeth()',
|
||||
]
|
||||
|
||||
# members vs exclude-members
|
||||
@@ -622,7 +622,7 @@ def test_autodoc_exclude_members(app):
|
||||
assert list(filter(lambda l: '::' in l, actual)) == [
|
||||
'.. py:class:: Base()',
|
||||
' .. py:attribute:: Base.inheritedattr',
|
||||
' .. py:method:: Base.inheritedclassmeth()'
|
||||
' .. py:method:: Base.inheritedclassmeth()',
|
||||
]
|
||||
|
||||
# exclude-members overrides autodoc_default_options
|
||||
@@ -634,7 +634,7 @@ def test_autodoc_exclude_members(app):
|
||||
'.. py:class:: Base()',
|
||||
' .. py:attribute:: Base.inheritedattr',
|
||||
' .. py:method:: Base.inheritedclassmeth()',
|
||||
' .. py:method:: Base.inheritedstaticmeth(cls)'
|
||||
' .. py:method:: Base.inheritedstaticmeth(cls)',
|
||||
]
|
||||
|
||||
# exclude-members extends autodoc_default_options
|
||||
@@ -668,7 +668,7 @@ def test_autodoc_exclude_members(app):
|
||||
' .. py:attribute:: Base.inheritedattr',
|
||||
' .. py:method:: Base.inheritedclassmeth()',
|
||||
' .. py:method:: Base.inheritedmeth()',
|
||||
' .. py:method:: Base.inheritedstaticmeth(cls)'
|
||||
' .. py:method:: Base.inheritedstaticmeth(cls)',
|
||||
]
|
||||
|
||||
|
||||
@@ -692,7 +692,7 @@ def test_autodoc_undoc_members(app):
|
||||
' .. py:attribute:: Class.skipattr',
|
||||
' .. py:method:: Class.skipmeth()',
|
||||
' .. py:attribute:: Class.udocattr',
|
||||
' .. py:method:: Class.undocmeth()'
|
||||
' .. py:method:: Class.undocmeth()',
|
||||
]
|
||||
|
||||
# use autodoc_default_options
|
||||
@@ -714,7 +714,7 @@ def test_autodoc_undoc_members(app):
|
||||
' .. py:attribute:: Class.skipattr',
|
||||
' .. py:method:: Class.skipmeth()',
|
||||
' .. py:attribute:: Class.udocattr',
|
||||
' .. py:method:: Class.undocmeth()'
|
||||
' .. py:method:: Class.undocmeth()',
|
||||
]
|
||||
|
||||
# options negation work check
|
||||
@@ -863,7 +863,7 @@ def test_autodoc_special_members(app):
|
||||
' .. py:attribute:: Class.skipattr',
|
||||
' .. py:method:: Class.skipmeth()',
|
||||
' .. py:attribute:: Class.udocattr',
|
||||
' .. py:method:: Class.undocmeth()'
|
||||
' .. py:method:: Class.undocmeth()',
|
||||
]
|
||||
|
||||
# specific special methods from autodoc_default_options
|
||||
@@ -919,7 +919,7 @@ def test_autodoc_ignore_module_all(app):
|
||||
'.. py:class:: InstAttCls()',
|
||||
'.. py:class:: Outer()',
|
||||
' .. py:class:: Outer.Inner()',
|
||||
'.. py:class:: StrRepr'
|
||||
'.. py:class:: StrRepr',
|
||||
]
|
||||
|
||||
|
||||
@@ -931,7 +931,7 @@ def test_autodoc_noindex(app):
|
||||
'',
|
||||
'.. py:module:: target',
|
||||
' :noindex:',
|
||||
''
|
||||
'',
|
||||
]
|
||||
|
||||
# TODO: :noindex: should be propagated to children of target item.
|
||||
@@ -942,7 +942,7 @@ def test_autodoc_noindex(app):
|
||||
'.. py:class:: Base()',
|
||||
' :noindex:',
|
||||
' :module: target.inheritance',
|
||||
''
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@@ -987,7 +987,7 @@ def test_autodoc_inner_class(app):
|
||||
' .. py:attribute:: Outer.factory',
|
||||
' :module: target',
|
||||
'',
|
||||
' alias of :py:class:`dict`'
|
||||
' alias of :py:class:`dict`',
|
||||
]
|
||||
|
||||
actual = do_autodoc(app, 'class', 'target.Outer.Inner', options)
|
||||
@@ -1068,7 +1068,7 @@ def test_autodoc_descriptor(app):
|
||||
' :module: target.descriptor',
|
||||
'',
|
||||
' Property.',
|
||||
''
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@@ -1114,7 +1114,7 @@ def test_autodoc_member_order(app):
|
||||
' .. py:attribute:: Class.inst_attr_inline',
|
||||
' .. py:attribute:: Class.inst_attr_comment',
|
||||
' .. py:attribute:: Class.inst_attr_string',
|
||||
' .. py:attribute:: Class._private_inst_attr'
|
||||
' .. py:attribute:: Class._private_inst_attr',
|
||||
]
|
||||
|
||||
# case member-order='groupwise'
|
||||
@@ -1139,7 +1139,7 @@ def test_autodoc_member_order(app):
|
||||
' .. py:attribute:: Class.inst_attr_string',
|
||||
' .. py:attribute:: Class.mdocattr',
|
||||
' .. py:attribute:: Class.skipattr',
|
||||
' .. py:attribute:: Class.udocattr'
|
||||
' .. py:attribute:: Class.udocattr',
|
||||
]
|
||||
|
||||
# case member-order=None
|
||||
@@ -1163,7 +1163,7 @@ def test_autodoc_member_order(app):
|
||||
' .. py:attribute:: Class.skipattr',
|
||||
' .. py:method:: Class.skipmeth()',
|
||||
' .. py:attribute:: Class.udocattr',
|
||||
' .. py:method:: Class.undocmeth()'
|
||||
' .. py:method:: Class.undocmeth()',
|
||||
]
|
||||
|
||||
|
||||
@@ -1251,7 +1251,7 @@ def test_class_attributes(app):
|
||||
' .. py:attribute:: AttCls.a2',
|
||||
' :module: target',
|
||||
' :value: None',
|
||||
''
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@@ -1299,7 +1299,7 @@ def test_autoclass_instance_attributes(app):
|
||||
' :module: target',
|
||||
'',
|
||||
' Docstring for instance attribute InstAttCls.ia2.',
|
||||
''
|
||||
'',
|
||||
]
|
||||
|
||||
# pick up arbitrary attributes
|
||||
@@ -1325,7 +1325,7 @@ def test_autoclass_instance_attributes(app):
|
||||
' :module: target',
|
||||
'',
|
||||
' Doc comment for instance attribute InstAttCls.ia1',
|
||||
''
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@@ -1338,7 +1338,7 @@ def test_autoattribute_instance_attributes(app):
|
||||
' :module: target',
|
||||
'',
|
||||
' Doc comment for instance attribute InstAttCls.ia1',
|
||||
''
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@@ -1463,7 +1463,7 @@ def test_enum_class(app):
|
||||
' :value: 12',
|
||||
'',
|
||||
' doc for val1',
|
||||
''
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@@ -1610,7 +1610,7 @@ def test_imported_partialfunction_should_not_shown_without_imported_members(app)
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:module:: target.imported_members',
|
||||
''
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@@ -2035,7 +2035,7 @@ def test_autodoc_for_egged_code(app):
|
||||
'',
|
||||
'.. py:function:: hello(s)',
|
||||
' :module: sample',
|
||||
''
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ def test_autodoc_inherit_docstrings(app):
|
||||
'',
|
||||
'.. py:method:: Derived.inheritedmeth()',
|
||||
' :module: target.inheritance',
|
||||
''
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@@ -997,7 +997,7 @@ def test_autodoc_typehints_description_no_undoc(app):
|
||||
'\n'
|
||||
' :param x: arg\n'
|
||||
' :return: another tuple\n',
|
||||
encoding='utf8'
|
||||
encoding='utf8',
|
||||
)
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
@@ -1050,7 +1050,7 @@ def test_autodoc_typehints_description_no_undoc_doc_rtype(app):
|
||||
'.. autofunction:: target.typehints.Math.horse\n'
|
||||
'\n'
|
||||
' :return: nothing\n',
|
||||
encoding='utf8'
|
||||
encoding='utf8',
|
||||
)
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
@@ -1097,7 +1097,7 @@ def test_autodoc_typehints_description_with_documented_init(app):
|
||||
(app.srcdir / 'index.rst').write_text(
|
||||
'.. autoclass:: target.typehints._ClassWithDocumentedInit\n'
|
||||
' :special-members: __init__\n',
|
||||
encoding='utf8'
|
||||
encoding='utf8',
|
||||
)
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
@@ -1136,7 +1136,7 @@ def test_autodoc_typehints_description_with_documented_init_no_undoc(app):
|
||||
(app.srcdir / 'index.rst').write_text(
|
||||
'.. autoclass:: target.typehints._ClassWithDocumentedInit\n'
|
||||
' :special-members: __init__\n',
|
||||
encoding='utf8'
|
||||
encoding='utf8',
|
||||
)
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
@@ -1168,7 +1168,7 @@ def test_autodoc_typehints_description_with_documented_init_no_undoc_doc_rtype(a
|
||||
(app.srcdir / 'index.rst').write_text(
|
||||
'.. autoclass:: target.typehints._ClassWithDocumentedInit\n'
|
||||
' :special-members: __init__\n',
|
||||
encoding='utf8'
|
||||
encoding='utf8',
|
||||
)
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
@@ -1206,7 +1206,7 @@ def test_autodoc_typehints_both(app):
|
||||
'.. autofunction:: target.typehints.tuple_args\n'
|
||||
'\n'
|
||||
'.. autofunction:: target.overload.sum\n',
|
||||
encoding='utf8'
|
||||
encoding='utf8',
|
||||
)
|
||||
app.build()
|
||||
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
@@ -1613,7 +1613,7 @@ def test_autodoc_default_options(app):
|
||||
# Note that :members: must be *on* for :special-members: to work.
|
||||
app.config.autodoc_default_options = {
|
||||
'members': None,
|
||||
'special-members': None
|
||||
'special-members': None,
|
||||
}
|
||||
actual = do_autodoc(app, 'class', 'target.CustomIter')
|
||||
assert ' .. py:method:: CustomIter.__init__()' in actual
|
||||
@@ -1698,7 +1698,7 @@ def test_autodoc_default_options_with_values(app):
|
||||
# with :exclude-members:
|
||||
app.config.autodoc_default_options = {
|
||||
'members': None,
|
||||
'exclude-members': 'val1'
|
||||
'exclude-members': 'val1',
|
||||
}
|
||||
actual = do_autodoc(app, 'class', 'target.enums.EnumCls')
|
||||
assert ' .. py:attribute:: EnumCls.val1' not in actual
|
||||
|
||||
@@ -34,8 +34,8 @@ default_kw = {
|
||||
'extensions': ['sphinx.ext.autosummary'],
|
||||
'autosummary_generate': True,
|
||||
'autosummary_generate_overwrite': False,
|
||||
'source_suffix': '.rst'
|
||||
}
|
||||
'source_suffix': '.rst',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ def test_inheritance_diagram(app, status, warning):
|
||||
('dummy.test.C', 'dummy.test.C', ['dummy.test.A'], None),
|
||||
('dummy.test.E', 'dummy.test.E', ['dummy.test.B'], None),
|
||||
('dummy.test.D', 'dummy.test.D', ['dummy.test.B', 'dummy.test.C'], None),
|
||||
('dummy.test.B', 'dummy.test.B', ['dummy.test.A'], None)
|
||||
('dummy.test.B', 'dummy.test.B', ['dummy.test.A'], None),
|
||||
]
|
||||
|
||||
# inheritance diagram using :parts: 1 option
|
||||
@@ -63,7 +63,7 @@ def test_inheritance_diagram(app, status, warning):
|
||||
('C', 'dummy.test.C', ['A'], None),
|
||||
('E', 'dummy.test.E', ['B'], None),
|
||||
('D', 'dummy.test.D', ['B', 'C'], None),
|
||||
('B', 'dummy.test.B', ['A'], None)
|
||||
('B', 'dummy.test.B', ['A'], None),
|
||||
]
|
||||
|
||||
# inheritance diagram with 1 top class
|
||||
@@ -82,7 +82,7 @@ def test_inheritance_diagram(app, status, warning):
|
||||
('dummy.test.C', 'dummy.test.C', ['dummy.test.A'], None),
|
||||
('dummy.test.E', 'dummy.test.E', ['dummy.test.B'], None),
|
||||
('dummy.test.D', 'dummy.test.D', ['dummy.test.B', 'dummy.test.C'], None),
|
||||
('dummy.test.B', 'dummy.test.B', [], None)
|
||||
('dummy.test.B', 'dummy.test.B', [], None),
|
||||
]
|
||||
|
||||
# inheritance diagram with 2 top classes
|
||||
@@ -100,7 +100,7 @@ def test_inheritance_diagram(app, status, warning):
|
||||
('dummy.test.C', 'dummy.test.C', [], None),
|
||||
('dummy.test.E', 'dummy.test.E', ['dummy.test.B'], None),
|
||||
('dummy.test.D', 'dummy.test.D', ['dummy.test.B', 'dummy.test.C'], None),
|
||||
('dummy.test.B', 'dummy.test.B', [], None)
|
||||
('dummy.test.B', 'dummy.test.B', [], None),
|
||||
]
|
||||
|
||||
# inheritance diagram with 2 top classes and specifying the entire module
|
||||
@@ -131,7 +131,7 @@ def test_inheritance_diagram(app, status, warning):
|
||||
assert cls in [
|
||||
('dummy.test_nested.A', 'dummy.test_nested.A', [], None),
|
||||
('dummy.test_nested.C', 'dummy.test_nested.C', ['dummy.test_nested.A.B'], None),
|
||||
('dummy.test_nested.A.B', 'dummy.test_nested.A.B', [], None)
|
||||
('dummy.test_nested.A.B', 'dummy.test_nested.A.B', [], None),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ class InlineAttributeTest(BaseDocstringTest):
|
||||
class GoogleDocstringTest(BaseDocstringTest):
|
||||
docstrings = [(
|
||||
"""Single line summary""",
|
||||
"""Single line summary"""
|
||||
"""Single line summary""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -144,7 +144,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
Single line summary
|
||||
|
||||
Extended description
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -158,7 +158,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
|
||||
:Parameters: **arg1** (*str*) -- Extended
|
||||
description of arg1
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -186,7 +186,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
description of kwarg1
|
||||
* **kwarg2** (*int*) -- Extended
|
||||
description of kwarg2
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -214,7 +214,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
description of kwarg1
|
||||
* **kwarg2** (*int*) -- Extended
|
||||
description of kwarg2
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -228,7 +228,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
|
||||
:returns: *str* -- Extended
|
||||
description of return value
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -242,7 +242,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
|
||||
:returns: *str* -- Extended
|
||||
description of return value
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -256,7 +256,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
|
||||
:returns: Extended
|
||||
description of return value
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -268,7 +268,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
Single line summary
|
||||
|
||||
:returns: Extended
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -286,7 +286,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
description of arg1
|
||||
* **\\*args** -- Variable length argument list.
|
||||
* **\\*\\*kwargs** -- Arbitrary keyword arguments.
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -304,7 +304,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
* **arg2** (*list[int]*) -- Description
|
||||
* **arg3** (*dict(str, int)*) -- Description
|
||||
* **arg4** (*dict[str, int]*) -- Description
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -318,7 +318,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
|
||||
:Receives: * **arg1** (*list(int)*) -- Description
|
||||
* **arg2** (*list[int]*) -- Description
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -332,7 +332,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
|
||||
:Receives: * **arg1** (*list(int)*) -- Description
|
||||
* **arg2** (*list[int]*) -- Description
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -346,7 +346,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
|
||||
:Yields: *str* -- Extended
|
||||
description of yielded value
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -360,7 +360,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
|
||||
:Yields: Extended
|
||||
description of yielded value
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -395,7 +395,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
description of arg5.
|
||||
* **arg6** (*list of int or float*) -- Extended
|
||||
description of arg6.
|
||||
"""
|
||||
""",
|
||||
)]
|
||||
|
||||
def test_sphinx_admonitions(self):
|
||||
@@ -439,7 +439,7 @@ class GoogleDocstringTest(BaseDocstringTest):
|
||||
config = Config(
|
||||
napoleon_use_param=False,
|
||||
napoleon_use_rtype=False,
|
||||
napoleon_use_keyword=False
|
||||
napoleon_use_keyword=False,
|
||||
)
|
||||
for docstring, expected in self.docstrings:
|
||||
actual = str(GoogleDocstring(dedent(docstring), config))
|
||||
@@ -1201,7 +1201,7 @@ Do as you please
|
||||
def test_pep526_annotations(self):
|
||||
# Test class attributes annotations
|
||||
config = Config(
|
||||
napoleon_attr_annotations=True
|
||||
napoleon_attr_annotations=True,
|
||||
)
|
||||
actual = str(GoogleDocstring(cleandoc(PEP526GoogleClass.__doc__), config, app=None, what="class",
|
||||
obj=PEP526GoogleClass))
|
||||
@@ -1250,7 +1250,7 @@ Do as you please
|
||||
class NumpyDocstringTest(BaseDocstringTest):
|
||||
docstrings = [(
|
||||
"""Single line summary""",
|
||||
"""Single line summary"""
|
||||
"""Single line summary""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -1262,7 +1262,7 @@ class NumpyDocstringTest(BaseDocstringTest):
|
||||
Single line summary
|
||||
|
||||
Extended description
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -1278,7 +1278,7 @@ class NumpyDocstringTest(BaseDocstringTest):
|
||||
|
||||
:Parameters: **arg1** (:class:`str`) -- Extended
|
||||
description of arg1
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -1313,7 +1313,7 @@ class NumpyDocstringTest(BaseDocstringTest):
|
||||
description of kwarg1
|
||||
* **kwarg2** (:class:`int`) -- Extended
|
||||
description of kwarg2
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -1329,7 +1329,7 @@ class NumpyDocstringTest(BaseDocstringTest):
|
||||
|
||||
:returns: :class:`str` -- Extended
|
||||
description of return value
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -1345,7 +1345,7 @@ class NumpyDocstringTest(BaseDocstringTest):
|
||||
|
||||
:returns: :class:`str` -- Extended
|
||||
description of return value
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -1365,7 +1365,7 @@ class NumpyDocstringTest(BaseDocstringTest):
|
||||
:Parameters: * **arg1** (:class:`str`) -- Extended description of arg1
|
||||
* **\\*args** -- Variable length argument list.
|
||||
* **\\*\\*kwargs** -- Arbitrary keyword arguments.
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -1382,7 +1382,7 @@ class NumpyDocstringTest(BaseDocstringTest):
|
||||
|
||||
:Parameters: * **arg1** (:class:`str`) -- Extended description of arg1
|
||||
* **\\*args, \\*\\*kwargs** -- Variable length argument list and arbitrary keyword arguments.
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -1403,7 +1403,7 @@ class NumpyDocstringTest(BaseDocstringTest):
|
||||
description of arg1
|
||||
* **arg2** (:class:`int`) -- Extended
|
||||
description of arg2
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -1424,7 +1424,7 @@ class NumpyDocstringTest(BaseDocstringTest):
|
||||
description of arg1
|
||||
* **arg2** (:class:`int`) -- Extended
|
||||
description of arg2
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -1440,7 +1440,7 @@ class NumpyDocstringTest(BaseDocstringTest):
|
||||
|
||||
:Yields: :class:`str` -- Extended
|
||||
description of yielded value
|
||||
"""
|
||||
""",
|
||||
), (
|
||||
"""
|
||||
Single line summary
|
||||
@@ -1456,7 +1456,7 @@ class NumpyDocstringTest(BaseDocstringTest):
|
||||
|
||||
:Yields: :class:`str` -- Extended
|
||||
description of yielded value
|
||||
"""
|
||||
""",
|
||||
)]
|
||||
|
||||
def test_sphinx_admonitions(self):
|
||||
@@ -2620,7 +2620,7 @@ class TestNumpyDocstring:
|
||||
def test_pep526_annotations(self):
|
||||
# test class attributes annotations
|
||||
config = Config(
|
||||
napoleon_attr_annotations=True
|
||||
napoleon_attr_annotations=True,
|
||||
)
|
||||
actual = str(NumpyDocstring(cleandoc(PEP526NumpyClass.__doc__), config, app=None, what="class",
|
||||
obj=PEP526NumpyClass))
|
||||
|
||||
@@ -14,7 +14,7 @@ def test_viewcode(app, status, warning):
|
||||
assert re.findall(
|
||||
r"index.rst:\d+: WARNING: Object named 'func1' not found in include " +
|
||||
r"file .*/spam/__init__.py'",
|
||||
warnings
|
||||
warnings,
|
||||
)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
@@ -112,7 +112,7 @@ def test_local_source_files(app, status, warning):
|
||||
assert re.findall(
|
||||
r"index.rst:\d+: WARNING: Object named 'func1' not found in include " +
|
||||
r"file .*/not_a_package/__init__.py'",
|
||||
warnings
|
||||
warnings,
|
||||
)
|
||||
|
||||
result = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
|
||||
@@ -165,22 +165,22 @@ def test_text_inconsistency_warnings(app, warning):
|
||||
warning_fmt % {
|
||||
'reftype': 'footnote references',
|
||||
'original': "\\['\\[#\\]_'\\]",
|
||||
'translated': "\\[\\]"
|
||||
'translated': "\\[\\]",
|
||||
} +
|
||||
warning_fmt % {
|
||||
'reftype': 'footnote references',
|
||||
'original': "\\['\\[100\\]_'\\]",
|
||||
'translated': "\\[\\]"
|
||||
'translated': "\\[\\]",
|
||||
} +
|
||||
warning_fmt % {
|
||||
'reftype': 'references',
|
||||
'original': "\\['reference_'\\]",
|
||||
'translated': "\\['reference_', 'reference_'\\]"
|
||||
'translated': "\\['reference_', 'reference_'\\]",
|
||||
} +
|
||||
warning_fmt % {
|
||||
'reftype': 'references',
|
||||
'original': "\\[\\]",
|
||||
'translated': "\\['`I18N WITH REFS INCONSISTENCY`_'\\]"
|
||||
'translated': "\\['`I18N WITH REFS INCONSISTENCY`_'\\]",
|
||||
})
|
||||
assert_re_search(expected_warning_expr, warnings)
|
||||
|
||||
@@ -1161,7 +1161,7 @@ def test_additional_targets_should_not_be_translated(app):
|
||||
'raw',
|
||||
'image',
|
||||
],
|
||||
}
|
||||
},
|
||||
)
|
||||
def test_additional_targets_should_be_translated(app):
|
||||
app.build()
|
||||
@@ -1242,7 +1242,7 @@ def test_text_references(app, warning):
|
||||
@pytest.mark.sphinx(
|
||||
'dummy', testroot='images',
|
||||
srcdir='test_intl_images',
|
||||
confoverrides={'language': 'xx'}
|
||||
confoverrides={'language': 'xx'},
|
||||
)
|
||||
@pytest.mark.xfail(os.name != 'posix', reason="Not working on windows")
|
||||
def test_image_glob_intl(app):
|
||||
@@ -1289,7 +1289,7 @@ def test_image_glob_intl(app):
|
||||
confoverrides={
|
||||
'language': 'xx',
|
||||
'figure_language_filename': '{root}{ext}.{language}',
|
||||
}
|
||||
},
|
||||
)
|
||||
@pytest.mark.xfail(os.name != 'posix', reason="Not working on windows")
|
||||
def test_image_glob_intl_using_figure_language_filename(app):
|
||||
@@ -1338,7 +1338,7 @@ def getwarning(warnings):
|
||||
srcdir='gettext_allow_fuzzy_translations',
|
||||
confoverrides={
|
||||
'language': 'de',
|
||||
'gettext_allow_fuzzy_translations': True
|
||||
'gettext_allow_fuzzy_translations': True,
|
||||
})
|
||||
def test_gettext_allow_fuzzy_translations(app):
|
||||
locale_dir = app.srcdir / 'locales' / 'de' / 'LC_MESSAGES'
|
||||
@@ -1357,7 +1357,7 @@ def test_gettext_allow_fuzzy_translations(app):
|
||||
srcdir='gettext_disallow_fuzzy_translations',
|
||||
confoverrides={
|
||||
'language': 'de',
|
||||
'gettext_allow_fuzzy_translations': False
|
||||
'gettext_allow_fuzzy_translations': False,
|
||||
})
|
||||
def test_gettext_disallow_fuzzy_translations(app):
|
||||
locale_dir = app.srcdir / 'locales' / 'de' / 'LC_MESSAGES'
|
||||
|
||||
@@ -158,7 +158,7 @@ def get_verifier(verify, verify_re):
|
||||
('\\sphinxAtStartPar\n'
|
||||
'\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}'
|
||||
'!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{https://peps.python.org/pep-0008/}'
|
||||
'{\\sphinxstylestrong{PEP 8}}')
|
||||
'{\\sphinxstylestrong{PEP 8}}'),
|
||||
),
|
||||
(
|
||||
# pep role with anchor
|
||||
@@ -171,7 +171,7 @@ def get_verifier(verify, verify_re):
|
||||
'\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}'
|
||||
'!PEP 8\\#id1@\\spxentry{PEP 8\\#id1}}\\sphinxhref'
|
||||
'{https://peps.python.org/pep-0008/\\#id1}'
|
||||
'{\\sphinxstylestrong{PEP 8\\#id1}}')
|
||||
'{\\sphinxstylestrong{PEP 8\\#id1}}'),
|
||||
),
|
||||
(
|
||||
# rfc role
|
||||
@@ -182,7 +182,7 @@ def get_verifier(verify, verify_re):
|
||||
('\\sphinxAtStartPar\n'
|
||||
'\\index{RFC@\\spxentry{RFC}!RFC 2324@\\spxentry{RFC 2324}}'
|
||||
'\\sphinxhref{https://datatracker.ietf.org/doc/html/rfc2324.html}'
|
||||
'{\\sphinxstylestrong{RFC 2324}}')
|
||||
'{\\sphinxstylestrong{RFC 2324}}'),
|
||||
),
|
||||
(
|
||||
# rfc role with anchor
|
||||
@@ -194,7 +194,7 @@ def get_verifier(verify, verify_re):
|
||||
('\\sphinxAtStartPar\n'
|
||||
'\\index{RFC@\\spxentry{RFC}!RFC 2324\\#id1@\\spxentry{RFC 2324\\#id1}}'
|
||||
'\\sphinxhref{https://datatracker.ietf.org/doc/html/rfc2324.html\\#id1}'
|
||||
'{\\sphinxstylestrong{RFC 2324\\#id1}}')
|
||||
'{\\sphinxstylestrong{RFC 2324\\#id1}}'),
|
||||
),
|
||||
(
|
||||
# correct interpretation of code with whitespace
|
||||
|
||||
@@ -152,7 +152,7 @@ def test_quickstart_all_answers(tempdir):
|
||||
ns = {}
|
||||
exec(conffile.read_text(encoding='utf8'), ns) # NoQA: S102
|
||||
assert ns['extensions'] == [
|
||||
'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo'
|
||||
'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
|
||||
]
|
||||
assert ns['templates_path'] == ['.templates']
|
||||
assert ns['source_suffix'] == '.txt'
|
||||
@@ -253,7 +253,7 @@ def test_exits_when_existing_confpy(monkeypatch):
|
||||
monkeypatch.setattr(path, 'isfile', mock_isfile)
|
||||
|
||||
qs.term_input = mock_input({
|
||||
'Please enter a new root path (or just Enter to exit)': ''
|
||||
'Please enter a new root path (or just Enter to exit)': '',
|
||||
})
|
||||
d = {}
|
||||
with pytest.raises(SystemExit):
|
||||
|
||||
@@ -160,7 +160,7 @@ def test_IndexBuilder():
|
||||
'comment': {'docname1_1', 'docname1_2', 'docname2_1', 'docname2_2'},
|
||||
'non': {'docname1_1', 'docname1_2', 'docname2_1', 'docname2_2'},
|
||||
'index': {'docname1_1', 'docname1_2', 'docname2_1', 'docname2_2'},
|
||||
'test': {'docname1_1', 'docname1_2', 'docname2_1', 'docname2_2'}
|
||||
'test': {'docname1_1', 'docname1_2', 'docname2_1', 'docname2_2'},
|
||||
}
|
||||
assert index._title_mapping == {'section_titl': {'docname1_1', 'docname1_2', 'docname2_1', 'docname2_2'}}
|
||||
assert index._objtypes == {}
|
||||
@@ -222,7 +222,7 @@ def test_IndexBuilder():
|
||||
'comment': {'docname1_2', 'docname2_2'},
|
||||
'non': {'docname1_2', 'docname2_2'},
|
||||
'index': {'docname1_2', 'docname2_2'},
|
||||
'test': {'docname1_2', 'docname2_2'}
|
||||
'test': {'docname1_2', 'docname2_2'},
|
||||
}
|
||||
assert index._title_mapping == {'section_titl': {'docname1_2', 'docname2_2'}}
|
||||
assert index._objtypes == {('dummy1', 'objtype1'): 0, ('dummy2', 'objtype1'): 1}
|
||||
@@ -267,7 +267,7 @@ def test_IndexBuilder_lookup():
|
||||
@pytest.mark.sphinx(
|
||||
testroot='search',
|
||||
confoverrides={'html_search_language': 'zh'},
|
||||
srcdir='search_zh'
|
||||
srcdir='search_zh',
|
||||
)
|
||||
def test_search_index_gen_zh(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
@@ -101,7 +101,7 @@ def test_NodeMatcher():
|
||||
|
||||
admonition body
|
||||
""",
|
||||
nodes.title, 1
|
||||
nodes.title, 1,
|
||||
),
|
||||
(
|
||||
"""
|
||||
@@ -144,7 +144,7 @@ def test_NodeMatcher():
|
||||
nodes.line, 2,
|
||||
|
||||
),
|
||||
]
|
||||
],
|
||||
)
|
||||
def test_extract_messages(rst, node_cls, count):
|
||||
msg = extract_messages(_get_doctree(dedent(rst)))
|
||||
@@ -228,7 +228,7 @@ def test_make_id_sequential(app):
|
||||
('hello <world>', (True, 'hello', 'world')),
|
||||
# explicit (title having angle brackets)
|
||||
('hello <world> <sphinx>', (True, 'hello <world>', 'sphinx')),
|
||||
]
|
||||
],
|
||||
)
|
||||
def test_split_explicit_target(title, expected):
|
||||
assert expected == split_explicit_title(title)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user