Skip to content

Commit a22dfab

Browse files
HeinischValentinValentinHeinischAA-Turner
authored
Permit filtering warnings generated during source code parsing (#13894)
Co-authored-by: Valentin Heinisch <[email protected]> Co-authored-by: Adam Turner <[email protected]>
1 parent 2d0a416 commit a22dfab

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Contributors
117117
* Thomas Waldmann -- apidoc module fixes
118118
* Till Hoffmann -- doctest option to exit after first failed test
119119
* Tim Hoffmann -- theme improvements
120+
* Valentin Heinisch -- warning types improvement
120121
* Victor Wheeler -- documentation improvements
121122
* Vince Salvino -- JavaScript search improvements
122123
* Will Maier -- directory HTML builder

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ Features added
102102
Patch by Matthias Geier.
103103
* #14029: intersphinx: Fix error in format string interpolation.
104104
Patch by Matthieu de Cibeins.
105+
* #13894: Add ``source_code_parser`` type to :confval:`suppress_warnings`
106+
for grouping issues related to the C and C++ parsers.
107+
Patch by Valentin H.
105108

106109
Bugs fixed
107110
----------

doc/usage/configuration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,8 @@ Options for warning control
14021402
* ``ref.python``
14031403
* ``ref.ref``
14041404
* ``ref.term``
1405+
* ``source_code_parser.c``
1406+
* ``source_code_parser.cpp``
14051407
* ``toc.circular``
14061408
* ``toc.duplicate_entry``
14071409
* ``toc.empty_glob``

sphinx/util/cfamily.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,10 @@ def fail(self, msg: str) -> NoReturn:
356356
raise self._make_multi_error(errors, '')
357357

358358
def warn(self, msg: str) -> None:
359-
logger.warning(msg, location=self.location)
359+
subtype = 'c' if self.language == 'C' else 'cpp'
360+
logger.warning(
361+
msg, location=self.location, type='source_code_parser', subtype=subtype
362+
)
360363

361364
def match(self, regex: re.Pattern[str]) -> bool:
362365
match = regex.match(self.definition, self.pos)

0 commit comments

Comments
 (0)