From 98042de48e1fb57c5a20b8b6384b014be4be17df Mon Sep 17 00:00:00 2001 From: Valentin Heinisch Date: Wed, 17 Sep 2025 16:18:04 +0200 Subject: [PATCH 1/6] use source_parser type for logging source parser issues --- sphinx/util/cfamily.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sphinx/util/cfamily.py b/sphinx/util/cfamily.py index 6071d90cf74..8cb19c87c32 100644 --- a/sphinx/util/cfamily.py +++ b/sphinx/util/cfamily.py @@ -356,7 +356,8 @@ def fail(self, msg: str) -> NoReturn: raise self._make_multi_error(errors, '') def warn(self, msg: str) -> None: - logger.warning(msg, location=self.location) + subtype = 'c' if self.language == 'C' else 'cpp' + logger.warning(msg, location=self.location, type='source_parser', subtype=subtype) def match(self, regex: re.Pattern[str]) -> bool: match = regex.match(self.definition, self.pos) From c7b6f93c1a3db0a852e037ffbb9ceac255cf03fc Mon Sep 17 00:00:00 2001 From: Valentin Heinisch Date: Wed, 17 Sep 2025 16:27:21 +0200 Subject: [PATCH 2/6] add changelog entry --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 64f94e14ec3..f915a81ce6b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -66,6 +66,8 @@ Features added Patch by Adam Turner. * #13805: LaTeX: add support for ``fontawesome7`` package. Patch by Jean-François B. +* Add ``source_parser`` type to :confval:`suppress_warnings` for grouping + issues related to the ``c`` and ``cpp`` source parsers. Bugs fixed ---------- From 3cb5f1b1cd36194cabf45a33842bea887ad07f17 Mon Sep 17 00:00:00 2001 From: Valentin Heinisch Date: Wed, 17 Sep 2025 16:29:37 +0200 Subject: [PATCH 3/6] adapt AUTHORS.rst --- AUTHORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index 5bcd74c943b..0a7b56f74e5 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -112,6 +112,7 @@ Contributors * Thomas Waldmann -- apidoc module fixes * Till Hoffmann -- doctest option to exit after first failed test * Tim Hoffmann -- theme improvements +* Valentin Heinisch -- warning types improvement * Victor Wheeler -- documentation improvements * Vince Salvino -- JavaScript search improvements * Will Maier -- directory HTML builder From f7f60170f617e903e33a3d9a3b001f0f88ec4de3 Mon Sep 17 00:00:00 2001 From: Valentin Heinisch Date: Wed, 17 Sep 2025 16:53:55 +0200 Subject: [PATCH 4/6] fix format --- sphinx/util/cfamily.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sphinx/util/cfamily.py b/sphinx/util/cfamily.py index 8cb19c87c32..9d1f300d497 100644 --- a/sphinx/util/cfamily.py +++ b/sphinx/util/cfamily.py @@ -357,7 +357,9 @@ def fail(self, msg: str) -> NoReturn: def warn(self, msg: str) -> None: subtype = 'c' if self.language == 'C' else 'cpp' - logger.warning(msg, location=self.location, type='source_parser', subtype=subtype) + logger.warning( + msg, location=self.location, type='source_parser', subtype=subtype + ) def match(self, regex: re.Pattern[str]) -> bool: match = regex.match(self.definition, self.pos) From 7aed12cbca35e2610596ceee9e7a028744385367 Mon Sep 17 00:00:00 2001 From: Valentin Heinisch Date: Wed, 17 Sep 2025 16:55:08 +0200 Subject: [PATCH 5/6] adapt changes --- CHANGES.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index f915a81ce6b..69eaeb41cbc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -66,8 +66,9 @@ Features added Patch by Adam Turner. * #13805: LaTeX: add support for ``fontawesome7`` package. Patch by Jean-François B. -* Add ``source_parser`` type to :confval:`suppress_warnings` for grouping +* #13894: Add ``source_parser`` type to :confval:`suppress_warnings` for grouping issues related to the ``c`` and ``cpp`` source parsers. + Patch by Valentin H. Bugs fixed ---------- From ca2c2ff4bf43865d1f386d8ee72b927812e6dcec Mon Sep 17 00:00:00 2001 From: Valentin Heinisch Date: Fri, 10 Oct 2025 12:13:59 +0200 Subject: [PATCH 6/6] add warning types to doc --- doc/usage/configuration.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index 5babd7e2915..343609109c6 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -1401,6 +1401,8 @@ Options for warning control * ``ref.python`` * ``ref.ref`` * ``ref.term`` + * ``source_parser.c`` + * ``source_parser.cpp`` * ``toc.circular`` * ``toc.duplicate_entry`` * ``toc.empty_glob``