mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Improve string concatenation (#12758)
Use implicit concatenation over ``+``, and combine some implicit concatenations to a single string literal.
This commit is contained in:
parent
18fbced7e0
commit
620e434f65
@ -495,9 +495,11 @@ class DefinitionParser(BaseParser):
|
|||||||
self.fail("Expected identifier in nested name, "
|
self.fail("Expected identifier in nested name, "
|
||||||
"got keyword: %s" % identifier)
|
"got keyword: %s" % identifier)
|
||||||
if self.matched_text in self.config.c_extra_keywords:
|
if self.matched_text in self.config.c_extra_keywords:
|
||||||
msg = "Expected identifier, got user-defined keyword: %s." \
|
msg = (
|
||||||
+ " Remove it from c_extra_keywords to allow it as identifier.\n" \
|
'Expected identifier, got user-defined keyword: %s.'
|
||||||
+ "Currently c_extra_keywords is %s."
|
' Remove it from c_extra_keywords to allow it as identifier.\n'
|
||||||
|
'Currently c_extra_keywords is %s.'
|
||||||
|
)
|
||||||
self.fail(msg % (self.matched_text,
|
self.fail(msg % (self.matched_text,
|
||||||
str(self.config.c_extra_keywords)))
|
str(self.config.c_extra_keywords)))
|
||||||
ident = ASTIdentifier(identifier)
|
ident = ASTIdentifier(identifier)
|
||||||
@ -670,9 +672,11 @@ class DefinitionParser(BaseParser):
|
|||||||
self.fail("Expected identifier, "
|
self.fail("Expected identifier, "
|
||||||
"got keyword: %s" % self.matched_text)
|
"got keyword: %s" % self.matched_text)
|
||||||
if self.matched_text in self.config.c_extra_keywords:
|
if self.matched_text in self.config.c_extra_keywords:
|
||||||
msg = "Expected identifier, got user-defined keyword: %s." \
|
msg = (
|
||||||
+ " Remove it from c_extra_keywords to allow it as identifier.\n" \
|
'Expected identifier, got user-defined keyword: %s. '
|
||||||
+ "Currently c_extra_keywords is %s."
|
'Remove it from c_extra_keywords to allow it as identifier.\n'
|
||||||
|
'Currently c_extra_keywords is %s.'
|
||||||
|
)
|
||||||
self.fail(msg % (self.matched_text,
|
self.fail(msg % (self.matched_text,
|
||||||
str(self.config.c_extra_keywords)))
|
str(self.config.c_extra_keywords)))
|
||||||
identifier = ASTIdentifier(self.matched_text)
|
identifier = ASTIdentifier(self.matched_text)
|
||||||
|
@ -1263,7 +1263,7 @@ class DefinitionParser(BaseParser):
|
|||||||
if self.skip_string('('):
|
if self.skip_string('('):
|
||||||
expr = self._parse_constant_expression(inTemplate=False)
|
expr = self._parse_constant_expression(inTemplate=False)
|
||||||
if not expr:
|
if not expr:
|
||||||
self.fail("Expected constant expression after '('" +
|
self.fail("Expected constant expression after '('"
|
||||||
" in explicit specifier.")
|
" in explicit specifier.")
|
||||||
self.skip_ws()
|
self.skip_ws()
|
||||||
if not self.skip_string(')'):
|
if not self.skip_string(')'):
|
||||||
@ -1972,13 +1972,14 @@ class DefinitionParser(BaseParser):
|
|||||||
if numArgs > numParams:
|
if numArgs > numParams:
|
||||||
numExtra = numArgs - numParams
|
numExtra = numArgs - numParams
|
||||||
if not fullSpecShorthand and not isMemberInstantiation:
|
if not fullSpecShorthand and not isMemberInstantiation:
|
||||||
msg = "Too many template argument lists compared to parameter" \
|
msg = (
|
||||||
" lists. Argument lists: %d, Parameter lists: %d," \
|
f'Too many template argument lists compared to parameter lists. '
|
||||||
" Extra empty parameters lists prepended: %d." \
|
f'Argument lists: {numArgs:d}, Parameter lists: {numParams:d}, '
|
||||||
% (numArgs, numParams, numExtra)
|
f'Extra empty parameters lists prepended: {numExtra:d}. '
|
||||||
msg += " Declaration:\n\t"
|
'Declaration:\n\t'
|
||||||
|
)
|
||||||
if templatePrefix:
|
if templatePrefix:
|
||||||
msg += "%s\n\t" % templatePrefix
|
msg += f"{templatePrefix}\n\t"
|
||||||
msg += str(nestedName)
|
msg += str(nestedName)
|
||||||
self.warn(msg)
|
self.warn(msg)
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ Note: By default this script will not overwrite already created files."""),
|
|||||||
'exclude_pattern',
|
'exclude_pattern',
|
||||||
nargs='*',
|
nargs='*',
|
||||||
help=__(
|
help=__(
|
||||||
'fnmatch-style file and/or directory patterns ' 'to exclude from generation'
|
'fnmatch-style file and/or directory patterns to exclude from generation'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -419,7 +419,7 @@ Note: By default this script will not overwrite already created files."""),
|
|||||||
dest='maxdepth',
|
dest='maxdepth',
|
||||||
type=int,
|
type=int,
|
||||||
default=4,
|
default=4,
|
||||||
help=__('maximum depth of submodules to show in the TOC ' '(default: 4)'),
|
help=__('maximum depth of submodules to show in the TOC (default: 4)'),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-f',
|
'-f',
|
||||||
@ -435,8 +435,7 @@ Note: By default this script will not overwrite already created files."""),
|
|||||||
dest='followlinks',
|
dest='followlinks',
|
||||||
default=False,
|
default=False,
|
||||||
help=__(
|
help=__(
|
||||||
'follow symbolic links. Powerful when combined '
|
'follow symbolic links. Powerful when combined with collective.recipe.omelette.'
|
||||||
'with collective.recipe.omelette.'
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@ -490,15 +489,14 @@ Note: By default this script will not overwrite already created files."""),
|
|||||||
'--module-first',
|
'--module-first',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
dest='modulefirst',
|
dest='modulefirst',
|
||||||
help=__('put module documentation before submodule ' 'documentation'),
|
help=__('put module documentation before submodule documentation'),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--implicit-namespaces',
|
'--implicit-namespaces',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
dest='implicit_namespaces',
|
dest='implicit_namespaces',
|
||||||
help=__(
|
help=__(
|
||||||
'interpret module paths according to PEP-0420 '
|
'interpret module paths according to PEP-0420 implicit namespaces specification'
|
||||||
'implicit namespaces specification'
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@ -559,7 +557,7 @@ Note: By default this script will not overwrite already created files."""),
|
|||||||
action='store',
|
action='store',
|
||||||
dest='release',
|
dest='release',
|
||||||
help=__(
|
help=__(
|
||||||
'project release, used when --full is given, ' 'defaults to --doc-version'
|
'project release, used when --full is given, defaults to --doc-version'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -803,7 +803,7 @@ The format of the autosummary directive is documented in the
|
|||||||
action='store',
|
action='store',
|
||||||
dest='suffix',
|
dest='suffix',
|
||||||
default='rst',
|
default='rst',
|
||||||
help=__('default suffix for files (default: ' '%(default)s)'),
|
help=__('default suffix for files (default: %(default)s)'),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-t',
|
'-t',
|
||||||
@ -811,7 +811,7 @@ The format of the autosummary directive is documented in the
|
|||||||
action='store',
|
action='store',
|
||||||
dest='templates',
|
dest='templates',
|
||||||
default=None,
|
default=None,
|
||||||
help=__('custom template directory (default: ' '%(default)s)'),
|
help=__('custom template directory (default: %(default)s)'),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-i',
|
'-i',
|
||||||
@ -819,7 +819,7 @@ The format of the autosummary directive is documented in the
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
dest='imported_members',
|
dest='imported_members',
|
||||||
default=False,
|
default=False,
|
||||||
help=__('document imported members (default: ' '%(default)s)'),
|
help=__('document imported members (default: %(default)s)'),
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-a',
|
'-a',
|
||||||
|
@ -455,7 +455,7 @@ class CoverageBuilder(Builder):
|
|||||||
if self.app.quiet or self.app.warningiserror:
|
if self.app.quiet or self.app.warningiserror:
|
||||||
for meth in methods:
|
for meth in methods:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
__('undocumented python method:' +
|
__('undocumented python method:'
|
||||||
' %s :: %s :: %s'),
|
' %s :: %s :: %s'),
|
||||||
name, class_name, meth)
|
name, class_name, meth)
|
||||||
else:
|
else:
|
||||||
|
@ -202,7 +202,7 @@ class _NodeUpdater:
|
|||||||
old_foot_refs = list(is_autofootnote_ref.findall(self.node))
|
old_foot_refs = list(is_autofootnote_ref.findall(self.node))
|
||||||
new_foot_refs = list(is_autofootnote_ref.findall(self.patch))
|
new_foot_refs = list(is_autofootnote_ref.findall(self.patch))
|
||||||
self.compare_references(old_foot_refs, new_foot_refs,
|
self.compare_references(old_foot_refs, new_foot_refs,
|
||||||
__('inconsistent footnote references in translated message.' +
|
__('inconsistent footnote references in translated message.'
|
||||||
' original: {0}, translated: {1}'))
|
' original: {0}, translated: {1}'))
|
||||||
old_foot_namerefs: dict[str, list[nodes.footnote_reference]] = {}
|
old_foot_namerefs: dict[str, list[nodes.footnote_reference]] = {}
|
||||||
for r in old_foot_refs:
|
for r in old_foot_refs:
|
||||||
@ -242,7 +242,7 @@ class _NodeUpdater:
|
|||||||
old_refs = list(is_refnamed_ref.findall(self.node))
|
old_refs = list(is_refnamed_ref.findall(self.node))
|
||||||
new_refs = list(is_refnamed_ref.findall(self.patch))
|
new_refs = list(is_refnamed_ref.findall(self.patch))
|
||||||
self.compare_references(old_refs, new_refs,
|
self.compare_references(old_refs, new_refs,
|
||||||
__('inconsistent references in translated message.' +
|
__('inconsistent references in translated message.'
|
||||||
' original: {0}, translated: {1}'))
|
' original: {0}, translated: {1}'))
|
||||||
old_ref_names = [r['refname'] for r in old_refs]
|
old_ref_names = [r['refname'] for r in old_refs]
|
||||||
new_ref_names = [r['refname'] for r in new_refs]
|
new_ref_names = [r['refname'] for r in new_refs]
|
||||||
@ -267,7 +267,7 @@ class _NodeUpdater:
|
|||||||
new_foot_refs = list(is_refnamed_footnote_ref.findall(self.patch))
|
new_foot_refs = list(is_refnamed_footnote_ref.findall(self.patch))
|
||||||
refname_ids_map: dict[str, list[str]] = {}
|
refname_ids_map: dict[str, list[str]] = {}
|
||||||
self.compare_references(old_foot_refs, new_foot_refs,
|
self.compare_references(old_foot_refs, new_foot_refs,
|
||||||
__('inconsistent footnote references in translated message.' +
|
__('inconsistent footnote references in translated message.'
|
||||||
' original: {0}, translated: {1}'))
|
' original: {0}, translated: {1}'))
|
||||||
for oldf in old_foot_refs:
|
for oldf in old_foot_refs:
|
||||||
refname_ids_map.setdefault(oldf["refname"], []).append(oldf["ids"])
|
refname_ids_map.setdefault(oldf["refname"], []).append(oldf["ids"])
|
||||||
@ -282,7 +282,7 @@ class _NodeUpdater:
|
|||||||
old_cite_refs = list(is_citation_ref.findall(self.node))
|
old_cite_refs = list(is_citation_ref.findall(self.node))
|
||||||
new_cite_refs = list(is_citation_ref.findall(self.patch))
|
new_cite_refs = list(is_citation_ref.findall(self.patch))
|
||||||
self.compare_references(old_cite_refs, new_cite_refs,
|
self.compare_references(old_cite_refs, new_cite_refs,
|
||||||
__('inconsistent citation references in translated message.' +
|
__('inconsistent citation references in translated message.'
|
||||||
' original: {0}, translated: {1}'))
|
' original: {0}, translated: {1}'))
|
||||||
refname_ids_map: dict[str, list[str]] = {}
|
refname_ids_map: dict[str, list[str]] = {}
|
||||||
for oldc in old_cite_refs:
|
for oldc in old_cite_refs:
|
||||||
@ -299,7 +299,7 @@ class _NodeUpdater:
|
|||||||
old_xrefs = [*self.node.findall(addnodes.pending_xref)]
|
old_xrefs = [*self.node.findall(addnodes.pending_xref)]
|
||||||
new_xrefs = [*self.patch.findall(addnodes.pending_xref)]
|
new_xrefs = [*self.patch.findall(addnodes.pending_xref)]
|
||||||
self.compare_references(old_xrefs, new_xrefs,
|
self.compare_references(old_xrefs, new_xrefs,
|
||||||
__('inconsistent term references in translated message.' +
|
__('inconsistent term references in translated message.'
|
||||||
' original: {0}, translated: {1}'))
|
' original: {0}, translated: {1}'))
|
||||||
|
|
||||||
xref_reftarget_map: dict[tuple[str, str, str] | None, dict[str, Any]] = {}
|
xref_reftarget_map: dict[tuple[str, str, str] | None, dict[str, Any]] = {}
|
||||||
|
@ -41,6 +41,6 @@ def test_html_code_role(app):
|
|||||||
'<span class="k">pass</span>')
|
'<span class="k">pass</span>')
|
||||||
assert ('<p>Inline <code class="code highlight python docutils literal highlight-python">' +
|
assert ('<p>Inline <code class="code highlight python docutils literal highlight-python">' +
|
||||||
common_content + '</code> code block</p>') in content
|
common_content + '</code> code block</p>') in content
|
||||||
assert ('<div class="highlight-python notranslate">' +
|
assert ('<div class="highlight-python notranslate">'
|
||||||
'<div class="highlight"><pre><span></span>' +
|
'<div class="highlight"><pre><span></span>' +
|
||||||
common_content) in content
|
common_content) in content
|
||||||
|
@ -1698,7 +1698,7 @@ def test_latex_code_role(app):
|
|||||||
r'\PYG{k}{pass}')
|
r'\PYG{k}{pass}')
|
||||||
assert (r'Inline \sphinxcode{\sphinxupquote{%' + '\n' +
|
assert (r'Inline \sphinxcode{\sphinxupquote{%' + '\n' +
|
||||||
common_content + '%\n}} code block') in content
|
common_content + '%\n}} code block') in content
|
||||||
assert (r'\begin{sphinxVerbatim}[commandchars=\\\{\}]' +
|
assert (r'\begin{sphinxVerbatim}[commandchars=\\\{\}]'
|
||||||
'\n' + common_content + '\n' + r'\end{sphinxVerbatim}') in content
|
'\n' + common_content + '\n' + r'\end{sphinxVerbatim}') in content
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ def _check_warnings(expected_warnings: str, warning: str) -> None:
|
|||||||
warnings = strip_colors(re.sub(re.escape(os.sep) + '{1,2}', '/', warning))
|
warnings = strip_colors(re.sub(re.escape(os.sep) + '{1,2}', '/', warning))
|
||||||
assert re.match(f'{expected_warnings}$', warnings), (
|
assert re.match(f'{expected_warnings}$', warnings), (
|
||||||
"Warnings don't match:\n"
|
"Warnings don't match:\n"
|
||||||
+ f'--- Expected (regex):\n{expected_warnings}\n'
|
f'--- Expected (regex):\n{expected_warnings}\n'
|
||||||
+ f'--- Got:\n{warnings}'
|
f'--- Got:\n{warnings}'
|
||||||
)
|
)
|
||||||
sys.modules.pop('autodoc_fodder', None)
|
sys.modules.pop('autodoc_fodder', None)
|
||||||
|
|
||||||
|
@ -302,8 +302,8 @@ def test_code_block(app):
|
|||||||
assert len(code_block) > 0
|
assert len(code_block) > 0
|
||||||
actual = code_block[0].text
|
actual = code_block[0].text
|
||||||
expect = (
|
expect = (
|
||||||
" def ruby?\n" +
|
" def ruby?\n"
|
||||||
" false\n" +
|
" false\n"
|
||||||
" end"
|
" end"
|
||||||
)
|
)
|
||||||
assert actual == expect
|
assert actual == expect
|
||||||
@ -333,8 +333,8 @@ def test_code_block_caption_latex(app):
|
|||||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||||
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstyleemphasis{test} rb}'
|
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstyleemphasis{test} rb}'
|
||||||
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id1}}}'
|
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id1}}}'
|
||||||
link = '\\hyperref[\\detokenize{caption:name-test-rb}]' \
|
link = ('\\hyperref[\\detokenize{caption:name-test-rb}]'
|
||||||
'{Listing \\ref{\\detokenize{caption:name-test-rb}}}'
|
'{Listing \\ref{\\detokenize{caption:name-test-rb}}}')
|
||||||
assert caption in latex
|
assert caption in latex
|
||||||
assert label in latex
|
assert label in latex
|
||||||
assert link in latex
|
assert link in latex
|
||||||
@ -345,12 +345,12 @@ def test_code_block_namedlink_latex(app):
|
|||||||
app.build(force_all=True)
|
app.build(force_all=True)
|
||||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||||
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-rb}}}'
|
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-rb}}}'
|
||||||
link1 = '\\hyperref[\\detokenize{caption:name-test-rb}]'\
|
link1 = ('\\hyperref[\\detokenize{caption:name-test-rb}]'
|
||||||
'{\\sphinxcrossref{\\DUrole{std,std-ref}{Ruby}}'
|
'{\\sphinxcrossref{\\DUrole{std,std-ref}{Ruby}}')
|
||||||
label2 = ('\\def\\sphinxLiteralBlockLabel'
|
label2 = ('\\def\\sphinxLiteralBlockLabel'
|
||||||
'{\\label{\\detokenize{namedblocks:some-ruby-code}}}')
|
'{\\label{\\detokenize{namedblocks:some-ruby-code}}}')
|
||||||
link2 = '\\hyperref[\\detokenize{namedblocks:some-ruby-code}]'\
|
link2 = ('\\hyperref[\\detokenize{namedblocks:some-ruby-code}]'
|
||||||
'{\\sphinxcrossref{\\DUrole{std,std-ref}{the ruby code}}}'
|
'{\\sphinxcrossref{\\DUrole{std,std-ref}{the ruby code}}}')
|
||||||
assert label1 in latex
|
assert label1 in latex
|
||||||
assert link1 in latex
|
assert link1 in latex
|
||||||
assert label2 in latex
|
assert label2 in latex
|
||||||
@ -453,8 +453,8 @@ def test_literalinclude_caption_latex(app):
|
|||||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||||
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstylestrong{test} py}'
|
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstylestrong{test} py}'
|
||||||
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id2}}}'
|
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id2}}}'
|
||||||
link = '\\hyperref[\\detokenize{caption:name-test-py}]' \
|
link = ('\\hyperref[\\detokenize{caption:name-test-py}]'
|
||||||
'{Listing \\ref{\\detokenize{caption:name-test-py}}}'
|
'{Listing \\ref{\\detokenize{caption:name-test-py}}}')
|
||||||
assert caption in latex
|
assert caption in latex
|
||||||
assert label in latex
|
assert label in latex
|
||||||
assert link in latex
|
assert link in latex
|
||||||
@ -465,12 +465,12 @@ def test_literalinclude_namedlink_latex(app):
|
|||||||
app.build(filenames='index')
|
app.build(filenames='index')
|
||||||
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
latex = (app.outdir / 'projectnamenotset.tex').read_text(encoding='utf8')
|
||||||
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-py}}}'
|
label1 = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:name-test-py}}}'
|
||||||
link1 = '\\hyperref[\\detokenize{caption:name-test-py}]'\
|
link1 = ('\\hyperref[\\detokenize{caption:name-test-py}]'
|
||||||
'{\\sphinxcrossref{\\DUrole{std,std-ref}{Python}}'
|
'{\\sphinxcrossref{\\DUrole{std,std-ref}{Python}}')
|
||||||
label2 = ('\\def\\sphinxLiteralBlockLabel'
|
label2 = ('\\def\\sphinxLiteralBlockLabel'
|
||||||
'{\\label{\\detokenize{namedblocks:some-python-code}}}')
|
'{\\label{\\detokenize{namedblocks:some-python-code}}}')
|
||||||
link2 = '\\hyperref[\\detokenize{namedblocks:some-python-code}]'\
|
link2 = ('\\hyperref[\\detokenize{namedblocks:some-python-code}]'
|
||||||
'{\\sphinxcrossref{\\DUrole{std,std-ref}{the python code}}}'
|
'{\\sphinxcrossref{\\DUrole{std,std-ref}{the python code}}}')
|
||||||
assert label1 in latex
|
assert label1 in latex
|
||||||
assert link1 in latex
|
assert link1 in latex
|
||||||
assert label2 in latex
|
assert label2 in latex
|
||||||
|
@ -55,8 +55,8 @@ def test_object_description_sections(app):
|
|||||||
|
|
||||||
|
|
||||||
def test_object_description_content_line_number(app):
|
def test_object_description_content_line_number(app):
|
||||||
text = (".. py:function:: foo(bar)\n" +
|
text = (".. py:function:: foo(bar)\n"
|
||||||
"\n" +
|
"\n"
|
||||||
" Some link here: :ref:`abc`\n")
|
" Some link here: :ref:`abc`\n")
|
||||||
doc = restructuredtext.parse(app, text)
|
doc = restructuredtext.parse(app, text)
|
||||||
xrefs = list(doc.findall(condition=addnodes.pending_xref))
|
xrefs = list(doc.findall(condition=addnodes.pending_xref))
|
||||||
|
@ -485,8 +485,8 @@ def test_domain_cpp_ast_function_definitions():
|
|||||||
check('function', 'bool namespaced::theclass::method(arg1, arg2)',
|
check('function', 'bool namespaced::theclass::method(arg1, arg2)',
|
||||||
{1: "namespaced::theclass::method__arg1.arg2",
|
{1: "namespaced::theclass::method__arg1.arg2",
|
||||||
2: "N10namespaced8theclass6methodE4arg14arg2"})
|
2: "N10namespaced8theclass6methodE4arg14arg2"})
|
||||||
x = 'std::vector<std::pair<std::string, int>> &module::test(register int ' \
|
x = ('std::vector<std::pair<std::string, int>> &module::test(register int '
|
||||||
'foo, bar, std::string baz = "foobar, blah, bleh") const = 0'
|
'foo, bar, std::string baz = "foobar, blah, bleh") const = 0')
|
||||||
check('function', x, {1: "module::test__i.bar.ssC",
|
check('function', x, {1: "module::test__i.bar.ssC",
|
||||||
2: "NK6module4testEi3barNSt6stringE"})
|
2: "NK6module4testEi3barNSt6stringE"})
|
||||||
check('function', 'void f(std::pair<A, B>)',
|
check('function', 'void f(std::pair<A, B>)',
|
||||||
@ -557,8 +557,8 @@ def test_domain_cpp_ast_function_definitions():
|
|||||||
check('function', 'MyClass::pointer MyClass::operator->()',
|
check('function', 'MyClass::pointer MyClass::operator->()',
|
||||||
{1: "MyClass::pointer-operator", 2: "N7MyClassptEv"})
|
{1: "MyClass::pointer-operator", 2: "N7MyClassptEv"})
|
||||||
|
|
||||||
x = 'std::vector<std::pair<std::string, int>> &module::test(register int ' \
|
x = ('std::vector<std::pair<std::string, int>> &module::test(register int '
|
||||||
'foo, bar[n], std::string baz = "foobar, blah, bleh") const = 0'
|
'foo, bar[n], std::string baz = "foobar, blah, bleh") const = 0')
|
||||||
check('function', x, {1: "module::test__i.barA.ssC",
|
check('function', x, {1: "module::test__i.barA.ssC",
|
||||||
2: "NK6module4testEiAn_3barNSt6stringE",
|
2: "NK6module4testEiAn_3barNSt6stringE",
|
||||||
3: "NK6module4testEiA1n_3barNSt6stringE"})
|
3: "NK6module4testEiA1n_3barNSt6stringE"})
|
||||||
@ -920,12 +920,12 @@ def test_domain_cpp_ast_requires_clauses():
|
|||||||
check('function', 'template<typename T> requires A && B || C and D void f()',
|
check('function', 'template<typename T> requires A && B || C and D void f()',
|
||||||
{4: 'I0EIQooaa1A1Baa1C1DE1fvv'})
|
{4: 'I0EIQooaa1A1Baa1C1DE1fvv'})
|
||||||
check('function',
|
check('function',
|
||||||
'template<typename T> requires R<T> ' +
|
'template<typename T> requires R<T> '
|
||||||
'template<typename U> requires S<T> ' +
|
'template<typename U> requires S<T> '
|
||||||
'void A<T>::f() requires B',
|
'void A<T>::f() requires B',
|
||||||
{4: 'I0EIQ1RI1TEEI0EIQaa1SI1TE1BEN1A1fEvv'})
|
{4: 'I0EIQ1RI1TEEI0EIQaa1SI1TE1BEN1A1fEvv'})
|
||||||
check('function',
|
check('function',
|
||||||
'template<template<typename T> requires R<T> typename X> ' +
|
'template<template<typename T> requires R<T> typename X> '
|
||||||
'void f()',
|
'void f()',
|
||||||
{2: 'II0EIQ1RI1TEE0E1fv', 4: 'II0EIQ1RI1TEE0E1fvv'})
|
{2: 'II0EIQ1RI1TEE0E1fv', 4: 'II0EIQ1RI1TEE0E1fvv'})
|
||||||
check('type',
|
check('type',
|
||||||
|
@ -234,8 +234,8 @@ def test_no_index_entry(app):
|
|||||||
|
|
||||||
|
|
||||||
def test_module_content_line_number(app):
|
def test_module_content_line_number(app):
|
||||||
text = (".. js:module:: foo\n" +
|
text = (".. js:module:: foo\n"
|
||||||
"\n" +
|
"\n"
|
||||||
" Some link here: :ref:`abc`\n")
|
" Some link here: :ref:`abc`\n")
|
||||||
doc = restructuredtext.parse(app, text)
|
doc = restructuredtext.parse(app, text)
|
||||||
xrefs = list(doc.findall(condition=addnodes.pending_xref))
|
xrefs = list(doc.findall(condition=addnodes.pending_xref))
|
||||||
|
@ -691,8 +691,8 @@ def test_domain_py_python_maximum_signature_line_length_in_text(app):
|
|||||||
|
|
||||||
|
|
||||||
def test_module_content_line_number(app):
|
def test_module_content_line_number(app):
|
||||||
text = (".. py:module:: foo\n" +
|
text = (".. py:module:: foo\n"
|
||||||
"\n" +
|
"\n"
|
||||||
" Some link here: :ref:`abc`\n")
|
" Some link here: :ref:`abc`\n")
|
||||||
doc = restructuredtext.parse(app, text)
|
doc = restructuredtext.parse(app, text)
|
||||||
xrefs = list(doc.findall(condition=addnodes.pending_xref))
|
xrefs = list(doc.findall(condition=addnodes.pending_xref))
|
||||||
|
@ -322,9 +322,10 @@ def test_toc_all_references_should_exist_pep420_enabled(make_app, apidoc):
|
|||||||
if not (outdir / filename).is_file():
|
if not (outdir / filename).is_file():
|
||||||
missing_files.append(filename)
|
missing_files.append(filename)
|
||||||
|
|
||||||
assert len(missing_files) == 0, \
|
all_missing = ', '.join(missing_files)
|
||||||
'File(s) referenced in TOC not found: {}\n' \
|
assert len(missing_files) == 0, (
|
||||||
'TOC:\n{}'.format(", ".join(missing_files), toc)
|
f'File(s) referenced in TOC not found: {all_missing}\nTOC:\n{toc}'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.apidoc(
|
@pytest.mark.apidoc(
|
||||||
@ -352,9 +353,10 @@ def test_toc_all_references_should_exist_pep420_disabled(make_app, apidoc):
|
|||||||
if not (outdir / filename).is_file():
|
if not (outdir / filename).is_file():
|
||||||
missing_files.append(filename)
|
missing_files.append(filename)
|
||||||
|
|
||||||
assert len(missing_files) == 0, \
|
all_missing = ', '.join(missing_files)
|
||||||
'File(s) referenced in TOC not found: {}\n' \
|
assert len(missing_files) == 0, (
|
||||||
'TOC:\n{}'.format(", ".join(missing_files), toc)
|
f'File(s) referenced in TOC not found: {all_missing}\nTOC:\n{toc}'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def extract_toc(path):
|
def extract_toc(path):
|
||||||
|
@ -186,8 +186,9 @@ def test_get_items_summary(make_app, app_params):
|
|||||||
'C.C2': 'This is a nested inner class docstring',
|
'C.C2': 'This is a nested inner class docstring',
|
||||||
}
|
}
|
||||||
for key, expected in expected_values.items():
|
for key, expected in expected_values.items():
|
||||||
assert autosummary_items[key][2] == expected, 'Summary for %s was %r -'\
|
assert autosummary_items[key][2] == expected, (
|
||||||
' expected %r' % (key, autosummary_items[key], expected)
|
f'Summary for {key} was {autosummary_items[key]!r} - expected {expected!r}'
|
||||||
|
)
|
||||||
|
|
||||||
# check an item in detail
|
# check an item in detail
|
||||||
assert 'func' in autosummary_items
|
assert 'func' in autosummary_items
|
||||||
|
@ -17,8 +17,8 @@ def test_ifconfig(app):
|
|||||||
|
|
||||||
def test_ifconfig_content_line_number(app):
|
def test_ifconfig_content_line_number(app):
|
||||||
app.setup_extension("sphinx.ext.ifconfig")
|
app.setup_extension("sphinx.ext.ifconfig")
|
||||||
text = (".. ifconfig:: confval1\n" +
|
text = (".. ifconfig:: confval1\n"
|
||||||
"\n" +
|
"\n"
|
||||||
" Some link here: :ref:`abc`\n")
|
" Some link here: :ref:`abc`\n")
|
||||||
doc = restructuredtext.parse(app, text)
|
doc = restructuredtext.parse(app, text)
|
||||||
xrefs = list(doc.findall(condition=addnodes.pending_xref))
|
xrefs = list(doc.findall(condition=addnodes.pending_xref))
|
||||||
|
@ -15,7 +15,7 @@ if TYPE_CHECKING:
|
|||||||
def check_viewcode_output(app: SphinxTestApp) -> str:
|
def check_viewcode_output(app: SphinxTestApp) -> str:
|
||||||
warnings = re.sub(r'\\+', '/', app.warning.getvalue())
|
warnings = re.sub(r'\\+', '/', app.warning.getvalue())
|
||||||
assert re.findall(
|
assert re.findall(
|
||||||
r"index.rst:\d+: WARNING: Object named 'func1' not found in include " +
|
r"index.rst:\d+: WARNING: Object named 'func1' not found in include "
|
||||||
r"file .*/spam/__init__.py'",
|
r"file .*/spam/__init__.py'",
|
||||||
warnings,
|
warnings,
|
||||||
)
|
)
|
||||||
@ -131,7 +131,7 @@ def test_local_source_files(app):
|
|||||||
|
|
||||||
warnings = re.sub(r'\\+', '/', app.warning.getvalue())
|
warnings = re.sub(r'\\+', '/', app.warning.getvalue())
|
||||||
assert re.findall(
|
assert re.findall(
|
||||||
r"index.rst:\d+: WARNING: Object named 'func1' not found in include " +
|
r"index.rst:\d+: WARNING: Object named 'func1' not found in include "
|
||||||
r"file .*/not_a_package/__init__.py'",
|
r"file .*/not_a_package/__init__.py'",
|
||||||
warnings,
|
warnings,
|
||||||
)
|
)
|
||||||
|
@ -1307,8 +1307,7 @@ def test_xml_label_targets(app):
|
|||||||
assert_elem(
|
assert_elem(
|
||||||
para3[0],
|
para3[0],
|
||||||
['X', 'bridge label',
|
['X', 'bridge label',
|
||||||
'IS NOT TRANSLATABLE BUT LINKED TO TRANSLATED ' +
|
'IS NOT TRANSLATABLE BUT LINKED TO TRANSLATED SECTION TITLE.'],
|
||||||
'SECTION TITLE.'],
|
|
||||||
['label-bridged-target-section'])
|
['label-bridged-target-section'])
|
||||||
assert_elem(
|
assert_elem(
|
||||||
para3[1],
|
para3[1],
|
||||||
|
Loading…
Reference in New Issue
Block a user