From: Vladimír Vondruš Date: Sat, 9 Jun 2018 15:07:23 +0000 (+0200) Subject: doxygen: warn if included code snippet is empty. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=6d6a52c40ca14d56baa20e6d9179a3d44b07cfd2;p=blog.git doxygen: warn if included code snippet is empty. Very useful since Doxygen stays silent in this case. --- diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index 542bc7f6..2f776acb 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -1147,6 +1147,12 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET. else: filename = i.attrib['filename'] + # Empty code block with a full filename -- probably a @skip / + # @skipline / ... that didn't match anything. Be nice and warn, + # because Doxygen doesn't. + if not filename.startswith('.') and not code.strip(): + logging.warning("{}: @include / @snippet / @skip[line] produced an empty code block, probably a wrong match expression?".format(state.current)) + # Custom mapping of filenames to languages mapping = [('.h', 'c++'), ('.h.cmake', 'c++'), diff --git a/doxygen/test/contents_code_language/input.dox b/doxygen/test/contents_code_language/input.dox index 12e19820..c8550a97 100644 --- a/doxygen/test/contents_code_language/input.dox +++ b/doxygen/test/contents_code_language/input.dox @@ -49,5 +49,10 @@ Another paragraph. Code that has unrecognizable format. @endcode +Snippet that doesn't match anything: + +@dontinclude code.sh +@skipline this is not there + */ diff --git a/doxygen/test/contents_code_language/warnings.html b/doxygen/test/contents_code_language/warnings.html index 7535d024..cc327243 100644 --- a/doxygen/test/contents_code_language/warnings.html +++ b/doxygen/test/contents_code_language/warnings.html @@ -23,7 +23,7 @@ Code that produces warnings
// Code without language
-// description
Code that has unrecognizable format.
+// description
Code that has unrecognizable format.

Snippet that doesn't match anything: