chiark / gitweb /
doxygen: warn when export macros are spotted in the output.
authorVladimír Vondruš <mosra@centrum.cz>
Thu, 18 Jan 2018 20:39:29 +0000 (21:39 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Thu, 18 Jan 2018 20:40:17 +0000 (21:40 +0100)
doxygen/dox2html5.py
doxygen/test/compound_warnings/Doxyfile [new file with mode: 0644]
doxygen/test/compound_warnings/File.h [new file with mode: 0644]
doxygen/test/compound_warnings/namespaceMagnum.html [new file with mode: 0644]
doxygen/test/test_compound.py

index f3d50d4dff2108984218d4792ef277b9bbb37fc2..e6bf2eb7b437911b032cdf5958429d182efa7d29 100755 (executable)
@@ -134,6 +134,10 @@ def parse_type(state: State, type: ET.Element) -> str:
 
         if i.tail: out += html.escape(i.tail)
 
+    # Warn if suspicious stuff is present
+    if '_EXPORT' in out or '_LOCAL' in out:
+        logging.warning("{}: type contains an export macro: {}".format(state.current, ''.join(type.itertext())))
+
     # Remove spacing inside <> and before & and *
     return fix_type_spacing(out)
 
diff --git a/doxygen/test/compound_warnings/Doxyfile b/doxygen/test/compound_warnings/Doxyfile
new file mode 100644 (file)
index 0000000..717f06b
--- /dev/null
@@ -0,0 +1,14 @@
+INPUT                   = File.h
+QUIET                   = YES
+GENERATE_HTML           = NO
+GENERATE_LATEX          = NO
+GENERATE_XML            = YES
+PREDEFINED              = DOXYGEN_GENERATING_OUTPUT
+
+# Enable to get rid of the MAGNUM_EXPORT macro in the output
+# MACRO_EXPANSION         = YES
+
+M_PAGE_FINE_PRINT       =
+M_THEME_COLOR           =
+M_LINKS_NAVBAR1         =
+M_LINKS_NAVBAR2         =
diff --git a/doxygen/test/compound_warnings/File.h b/doxygen/test/compound_warnings/File.h
new file mode 100644 (file)
index 0000000..1af0ace
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef DOXYGEN_GENERATING_OUTPUT
+#define MAGNUM_EXPORT __attribute__ ((visibility ("default")))
+#else
+#define MAGNUM_EXPORT
+#endif
+
+/** @brief Root namespace */
+namespace Magnum {
+
+/** @brief Always returns `true` */
+constexpr bool MAGNUM_EXPORT hasCoolThings() { return true; }
+
+}
diff --git a/doxygen/test/compound_warnings/namespaceMagnum.html b/doxygen/test/compound_warnings/namespaceMagnum.html
new file mode 100644 (file)
index 0000000..5d9f290
--- /dev/null
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>Magnum namespace | My Project</title>
+  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+  <link rel="stylesheet" href="m-dark+doxygen.compiled.css" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+  <div class="m-container">
+    <div class="m-row">
+      <a href="index.html" id="m-navbar-brand" class="m-col-t-9 m-col-m-none m-left-m">My Project</a>
+    </div>
+  </div>
+</nav></header>
+<main><article>
+  <div class="m-container m-container-inflatable">
+    <div class="m-row">
+      <div class="m-col-l-10 m-push-l-1">
+        <h1>Magnum <span class="m-thin">namespace</span></h1>
+        <p>Root namespace.</p>
+        <div class="m-block m-default">
+          <h3>Contents</h3>
+          <ul>
+            <li>
+              Reference
+              <ul>
+                <li><a href="#func-members">Functions</a></li>
+              </ul>
+            </li>
+          </ul>
+        </div>
+        <section id="func-members">
+          <h2><a href="#func-members">Functions</a></h3>
+          <dl class="m-dox">
+            <dt>
+              <span class="m-dox-wrap-bumper">auto <a href="#a7f3d59790996b9f86ca6d4adc63549e2" class="m-dox-self" name="a7f3d59790996b9f86ca6d4adc63549e2">hasCoolThings</a>(</span><span class="m-dox-wrap">) -&gt; bool MAGNUM_EXPORT <span class="m-label m-flat m-primary">constexpr</span></span>
+            </dt>
+            <dd>Always returns <code>true</code></dd>
+          </dl>
+        </section>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
index 8eb08d7bc7cdd93286f68eeb8bdc717847e13576..7d5ae41b78a25db6e0fd29b5c8848df85930d13e 100644 (file)
@@ -129,3 +129,12 @@ class Ignored(IntegrationTestCase):
     def test_empty_class_doc_not_generated(self):
         self.run_dox2html5(index_pages=[], wildcard='classBrief.xml')
         self.assertFalse(os.path.exists(os.path.join(self.path, 'html', 'classBrief.html')))
+
+class Warnings(IntegrationTestCase):
+    def __init__(self, *args, **kwargs):
+        super().__init__(__file__, 'warnings', *args, **kwargs)
+
+    def test(self):
+        # Should warn that an export macro is present in the XML
+        self.run_dox2html5(wildcard='namespaceMagnum.xml')
+        self.assertEqual(*self.actual_expected_contents('namespaceMagnum.html'))