Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn show_warning_types on by default #12597

Merged
merged 5 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ Incompatible changes
* :confval:`linkcheck_report_timeouts_as_broken` is now ``False`` by default.

Patch by James Addison.
* #12597: Change the default of :confval:`show_warning_types`
from ``False``to ``True``.
Patch by Chris Sewell.

Deprecated
----------
Expand Down
4 changes: 3 additions & 1 deletion doc/usage/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1331,14 +1331,16 @@ Options for warning control

.. confval:: show_warning_types
:type: :code-py:`bool`
:default: :code-py:`False`
:default: :code-py:`True`

Add the type of each warning as a suffix to the warning message.
For example, ``WARNING: [...] [index]`` or ``WARNING: [...] [toc.circular]``.
This setting can be useful for determining which warnings types to include
in a :confval:`suppress_warnings` list.

.. versionadded:: 7.3.0
.. versionchanged:: 8.0.0
The default is now :code-py:`True`.

.. confval:: suppress_warnings
:type: :code-py:`Sequence[str]`
Expand Down
2 changes: 1 addition & 1 deletion sphinx/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class Config:
'template_bridge': _Opt(None, 'html', frozenset((str,))),
'keep_warnings': _Opt(False, 'env', ()),
'suppress_warnings': _Opt([], 'env', ()),
'show_warning_types': _Opt(False, 'env', frozenset((bool,))),
'show_warning_types': _Opt(True, 'env', frozenset((bool,))),
'modindex_common_prefix': _Opt([], 'html', ()),
'rst_epilog': _Opt(None, 'env', frozenset((str,))),
'rst_prolog': _Opt(None, 'env', frozenset((str,))),
Expand Down
24 changes: 12 additions & 12 deletions tests/test_builders/test_build_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@

ENV_WARNINGS = """\
{root}/autodoc_fodder.py:docstring of autodoc_fodder.MarkupError:\\d+: \
WARNING: Explicit markup ends without a blank line; unexpected unindent.
WARNING: Explicit markup ends without a blank line; unexpected unindent. \\[docutils\\]
{root}/index.rst:\\d+: WARNING: Encoding 'utf-8-sig' used for reading included \
file '{root}/wrongenc.inc' seems to be wrong, try giving an :encoding: option
file '{root}/wrongenc.inc' seems to be wrong, try giving an :encoding: option \\[docutils\\]
{root}/index.rst:\\d+: WARNING: invalid single index entry ''
{root}/index.rst:\\d+: WARNING: image file not readable: foo.png
{root}/index.rst:\\d+: WARNING: download file not readable: {root}/nonexisting.png
{root}/index.rst:\\d+: WARNING: image file not readable: foo.png \\[image.not_readable\\]
{root}/index.rst:\\d+: WARNING: download file not readable: {root}/nonexisting.png \\[download.not_readable\\]
{root}/undecodable.rst:\\d+: WARNING: undecodable source characters, replacing \
with "\\?": b?'here: >>>(\\\\|/)xbb<<<((\\\\|/)r)?'
"""

HTML_WARNINGS = ENV_WARNINGS + """\
{root}/index.rst:\\d+: WARNING: unknown option: '&option'
{root}/index.rst:\\d+: WARNING: citation not found: missing
{root}/index.rst:\\d+: WARNING: unknown option: '&option' \\[ref.option\\]
{root}/index.rst:\\d+: WARNING: citation not found: missing \\[ref.ref\\]
{root}/index.rst:\\d+: WARNING: a suitable image for html builder not found: foo.\\*
{root}/index.rst:\\d+: WARNING: Lexing literal_block ".*" as "c" resulted in an error at token: ".*". Retrying in relaxed mode.
{root}/index.rst:\\d+: WARNING: Lexing literal_block ".*" as "c" resulted in an error at token: ".*". Retrying in relaxed mode. \\[misc.highlighting_failure\\]
"""

LATEX_WARNINGS = ENV_WARNINGS + """\
{root}/index.rst:\\d+: WARNING: unknown option: '&option'
{root}/index.rst:\\d+: WARNING: citation not found: missing
{root}/index.rst:\\d+: WARNING: unknown option: '&option' \\[ref.option\\]
{root}/index.rst:\\d+: WARNING: citation not found: missing \\[ref.ref\\]
{root}/index.rst:\\d+: WARNING: a suitable image for latex builder not found: foo.\\*
{root}/index.rst:\\d+: WARNING: Lexing literal_block ".*" as "c" resulted in an error at token: ".*". Retrying in relaxed mode.
{root}/index.rst:\\d+: WARNING: Lexing literal_block ".*" as "c" resulted in an error at token: ".*". Retrying in relaxed mode. \\[misc.highlighting_failure\\]
"""

TEXINFO_WARNINGS = ENV_WARNINGS + """\
{root}/index.rst:\\d+: WARNING: unknown option: '&option'
{root}/index.rst:\\d+: WARNING: citation not found: missing
{root}/index.rst:\\d+: WARNING: unknown option: '&option' \\[ref.option\\]
{root}/index.rst:\\d+: WARNING: citation not found: missing \\[ref.ref\\]
{root}/index.rst:\\d+: WARNING: a suitable image for texinfo builder not found: foo.\\*
{root}/index.rst:\\d+: WARNING: a suitable image for texinfo builder not found: \
\\['application/pdf', 'image/svg\\+xml'\\] \\(svgimg.\\*\\)
Expand Down
16 changes: 8 additions & 8 deletions tests/test_extensions/test_ext_intersphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,14 @@ def test_intersphinx_role(app, warning):
warnings = strip_colors(warning.getvalue()).splitlines()
index_path = app.srcdir / 'index.rst'
assert warnings == [
f"{index_path}:21: WARNING: role for external cross-reference not found in domain 'py': 'nope'",
f"{index_path}:28: WARNING: role for external cross-reference not found in domains 'cpp', 'std': 'nope'",
f"{index_path}:39: WARNING: inventory for external cross-reference not found: 'invNope'",
f"{index_path}:44: WARNING: role for external cross-reference not found in domain 'c': 'function' (perhaps you meant one of: 'func', 'identifier', 'type')",
f"{index_path}:45: WARNING: role for external cross-reference not found in domains 'cpp', 'std': 'function' (perhaps you meant one of: 'cpp:func', 'cpp:identifier', 'cpp:type')",
f'{index_path}:9: WARNING: external py:mod reference target not found: module3',
f'{index_path}:14: WARNING: external py:mod reference target not found: module10',
f'{index_path}:19: WARNING: external py:meth reference target not found: inv:Foo.bar',
f"{index_path}:21: WARNING: role for external cross-reference not found in domain 'py': 'nope' [intersphinx.external]",
f"{index_path}:28: WARNING: role for external cross-reference not found in domains 'cpp', 'std': 'nope' [intersphinx.external]",
f"{index_path}:39: WARNING: inventory for external cross-reference not found: 'invNope' [intersphinx.external]",
f"{index_path}:44: WARNING: role for external cross-reference not found in domain 'c': 'function' (perhaps you meant one of: 'func', 'identifier', 'type') [intersphinx.external]",
f"{index_path}:45: WARNING: role for external cross-reference not found in domains 'cpp', 'std': 'function' (perhaps you meant one of: 'cpp:func', 'cpp:identifier', 'cpp:type') [intersphinx.external]",
f'{index_path}:9: WARNING: external py:mod reference target not found: module3 [ref.mod]',
f'{index_path}:14: WARNING: external py:mod reference target not found: module10 [ref.mod]',
f'{index_path}:19: WARNING: external py:meth reference target not found: inv:Foo.bar [ref.meth]',
]

html = '<a class="reference external" href="https://example.org/{}" title="(in foo v2.0)">'
Expand Down
6 changes: 3 additions & 3 deletions tests/test_intl/test_intl.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_text_emit_warnings(app, warning):
# test warnings in translation
warnings = getwarning(warning)
warning_expr = ('.*/warnings.txt:4:<translated>:1: '
'WARNING: Inline literal start-string without end-string.\n')
'WARNING: Inline literal start-string without end-string. \\[docutils\\]\n')
assert re.search(warning_expr, warnings), f'{warning_expr!r} did not match {warnings!r}'


Expand Down Expand Up @@ -156,7 +156,7 @@ def test_text_inconsistency_warnings(app, warning):
warnings = getwarning(warning)
warning_fmt = ('.*/refs_inconsistency.txt:\\d+: '
'WARNING: inconsistent %(reftype)s in translated message.'
' original: %(original)s, translated: %(translated)s\n')
' original: %(original)s, translated: %(translated)s \\[i18n.inconsistent_references\\]\n')
expected_warning_expr = (
warning_fmt % {
'reftype': 'footnote references',
Expand Down Expand Up @@ -310,7 +310,7 @@ def test_text_glossary_term_inconsistencies(app, warning):
'.*/glossary_terms_inconsistency.txt:\\d+: '
'WARNING: inconsistent term references in translated message.'
" original: \\[':term:`Some term`', ':term:`Some other term`'\\],"
" translated: \\[':term:`SOME NEW TERM`'\\]\n")
" translated: \\[':term:`SOME NEW TERM`'\\] \\[i18n.inconsistent_references\\]\n")
assert re.search(expected_warning_expr, warnings), f'{expected_warning_expr!r} did not match {warnings!r}'
expected_warning_expr = (
'.*/glossary_terms_inconsistency.txt:\\d+:<translated>:1: '
Expand Down
Loading