From: Vladimír Vondruš Date: Thu, 18 Jan 2018 20:39:29 +0000 (+0100) Subject: doxygen: warn when export macros are spotted in the output. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=05bd3b1075acd3a81f821a18929df4c42b1a563c;p=blog.git doxygen: warn when export macros are spotted in the output. --- diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index f3d50d4d..e6bf2eb7 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -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 index 00000000..717f06b9 --- /dev/null +++ b/doxygen/test/compound_warnings/Doxyfile @@ -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 index 00000000..1af0ace6 --- /dev/null +++ b/doxygen/test/compound_warnings/File.h @@ -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 index 00000000..5d9f290b --- /dev/null +++ b/doxygen/test/compound_warnings/namespaceMagnum.html @@ -0,0 +1,49 @@ + + + + + Magnum namespace | My Project + + + + + +
+
+
+
+
+

Magnum namespace

+

Root namespace.

+
+

Contents

+ +
+
+

Functions

+
+
+ auto hasCoolThings() -> bool MAGNUM_EXPORT constexpr +
+
Always returns true
+
+
+
+
+
+
+ + diff --git a/doxygen/test/test_compound.py b/doxygen/test/test_compound.py index 8eb08d7b..7d5ae41b 100644 --- a/doxygen/test/test_compound.py +++ b/doxygen/test/test_compound.py @@ -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'))