chiark / gitweb /
doxygen: warn if included code snippet is empty.
authorVladimír Vondruš <mosra@centrum.cz>
Sat, 9 Jun 2018 15:07:23 +0000 (17:07 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 9 Jun 2018 15:07:23 +0000 (17:07 +0200)
Very useful since Doxygen stays silent in this case.

doxygen/dox2html5.py
doxygen/test/contents_code_language/input.dox
doxygen/test/contents_code_language/warnings.html

index 542bc7f67a0a64b48eadc1d479b5e9c79aac690c..2f776acbfe0ec4351c7fc3d39f9cc4132ba3ad91 100755 (executable)
@@ -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++'),
index 12e19820a6c74edbee126bfa9c0c8f9716c62efb..c8550a9743a9d7ef38c47ea8500adcef51b1f195 100644 (file)
@@ -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
+
 */
 
index 7535d024ec8cae5c03f66ce57895693da83959a0..cc327243fde004d33da5ad2dd259eb83bd66c72a 100644 (file)
@@ -23,7 +23,7 @@
           Code that produces warnings
         </h1>
 <pre class="m-code"><span class="c1">// Code without language</span>
-<span class="c1">// description</span></pre><pre class="m-code">Code that has unrecognizable format.</pre>
+<span class="c1">// description</span></pre><pre class="m-code">Code that has unrecognizable format.</pre><p>Snippet that doesn&#x27;t match anything:</p><pre class="m-code"></pre>
       </div>
     </div>
   </div>