Skip to content

Commit dabacdf

Browse files
Turn show_warning_types on by default (sphinx-doc#12597)
Co-authored-by: Adam Turner <[email protected]>
1 parent cc08854 commit dabacdf

File tree

6 files changed

+30
-25
lines changed

6 files changed

+30
-25
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ Incompatible changes
5757
* :confval:`linkcheck_report_timeouts_as_broken` is now ``False`` by default.
5858

5959
Patch by James Addison.
60+
* #12597: Change the default of :confval:`show_warning_types`
61+
from ``False`` to ``True``.
62+
Patch by Chris Sewell.
6063

6164
Deprecated
6265
----------

doc/usage/configuration.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,14 +1331,16 @@ Options for warning control
13311331

13321332
.. confval:: show_warning_types
13331333
:type: :code-py:`bool`
1334-
:default: :code-py:`False`
1334+
:default: :code-py:`True`
13351335

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

13411341
.. versionadded:: 7.3.0
1342+
.. versionchanged:: 8.0.0
1343+
The default is now :code-py:`True`.
13421344

13431345
.. confval:: suppress_warnings
13441346
:type: :code-py:`Sequence[str]`

sphinx/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class Config:
244244
'template_bridge': _Opt(None, 'html', frozenset((str,))),
245245
'keep_warnings': _Opt(False, 'env', ()),
246246
'suppress_warnings': _Opt([], 'env', ()),
247-
'show_warning_types': _Opt(False, 'env', frozenset((bool,))),
247+
'show_warning_types': _Opt(True, 'env', frozenset((bool,))),
248248
'modindex_common_prefix': _Opt([], 'html', ()),
249249
'rst_epilog': _Opt(None, 'env', frozenset((str,))),
250250
'rst_prolog': _Opt(None, 'env', frozenset((str,))),

tests/test_builders/test_build_warnings.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,33 @@
88

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

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

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

3535
TEXINFO_WARNINGS = ENV_WARNINGS + """\
36-
{root}/index.rst:\\d+: WARNING: unknown option: '&option'
37-
{root}/index.rst:\\d+: WARNING: citation not found: missing
36+
{root}/index.rst:\\d+: WARNING: unknown option: '&option' \\[ref.option\\]
37+
{root}/index.rst:\\d+: WARNING: citation not found: missing \\[ref.ref\\]
3838
{root}/index.rst:\\d+: WARNING: a suitable image for texinfo builder not found: foo.\\*
3939
{root}/index.rst:\\d+: WARNING: a suitable image for texinfo builder not found: \
4040
\\['application/pdf', 'image/svg\\+xml'\\] \\(svgimg.\\*\\)

tests/test_extensions/test_ext_intersphinx.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -575,14 +575,14 @@ def test_intersphinx_role(app, warning):
575575
warnings = strip_colors(warning.getvalue()).splitlines()
576576
index_path = app.srcdir / 'index.rst'
577577
assert warnings == [
578-
f"{index_path}:21: WARNING: role for external cross-reference not found in domain 'py': 'nope'",
579-
f"{index_path}:28: WARNING: role for external cross-reference not found in domains 'cpp', 'std': 'nope'",
580-
f"{index_path}:39: WARNING: inventory for external cross-reference not found: 'invNope'",
581-
f"{index_path}:44: WARNING: role for external cross-reference not found in domain 'c': 'function' (perhaps you meant one of: 'func', 'identifier', 'type')",
582-
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')",
583-
f'{index_path}:9: WARNING: external py:mod reference target not found: module3',
584-
f'{index_path}:14: WARNING: external py:mod reference target not found: module10',
585-
f'{index_path}:19: WARNING: external py:meth reference target not found: inv:Foo.bar',
578+
f"{index_path}:21: WARNING: role for external cross-reference not found in domain 'py': 'nope' [intersphinx.external]",
579+
f"{index_path}:28: WARNING: role for external cross-reference not found in domains 'cpp', 'std': 'nope' [intersphinx.external]",
580+
f"{index_path}:39: WARNING: inventory for external cross-reference not found: 'invNope' [intersphinx.external]",
581+
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]",
582+
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]",
583+
f'{index_path}:9: WARNING: external py:mod reference target not found: module3 [ref.mod]',
584+
f'{index_path}:14: WARNING: external py:mod reference target not found: module10 [ref.mod]',
585+
f'{index_path}:19: WARNING: external py:meth reference target not found: inv:Foo.bar [ref.meth]',
586586
]
587587

588588
html = '<a class="reference external" href="https://example.org/{}" title="(in foo v2.0)">'

tests/test_intl/test_intl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_text_emit_warnings(app, warning):
9696
# test warnings in translation
9797
warnings = getwarning(warning)
9898
warning_expr = ('.*/warnings.txt:4:<translated>:1: '
99-
'WARNING: Inline literal start-string without end-string.\n')
99+
'WARNING: Inline literal start-string without end-string. \\[docutils\\]\n')
100100
assert re.search(warning_expr, warnings), f'{warning_expr!r} did not match {warnings!r}'
101101

102102

@@ -156,7 +156,7 @@ def test_text_inconsistency_warnings(app, warning):
156156
warnings = getwarning(warning)
157157
warning_fmt = ('.*/refs_inconsistency.txt:\\d+: '
158158
'WARNING: inconsistent %(reftype)s in translated message.'
159-
' original: %(original)s, translated: %(translated)s\n')
159+
' original: %(original)s, translated: %(translated)s \\[i18n.inconsistent_references\\]\n')
160160
expected_warning_expr = (
161161
warning_fmt % {
162162
'reftype': 'footnote references',
@@ -310,7 +310,7 @@ def test_text_glossary_term_inconsistencies(app, warning):
310310
'.*/glossary_terms_inconsistency.txt:\\d+: '
311311
'WARNING: inconsistent term references in translated message.'
312312
" original: \\[':term:`Some term`', ':term:`Some other term`'\\],"
313-
" translated: \\[':term:`SOME NEW TERM`'\\]\n")
313+
" translated: \\[':term:`SOME NEW TERM`'\\] \\[i18n.inconsistent_references\\]\n")
314314
assert re.search(expected_warning_expr, warnings), f'{expected_warning_expr!r} did not match {warnings!r}'
315315
expected_warning_expr = (
316316
'.*/glossary_terms_inconsistency.txt:\\d+:<translated>:1: '

0 commit comments

Comments
 (0)