From: Vladimír Vondruš Date: Fri, 29 Mar 2019 18:07:40 +0000 (+0100) Subject: doxygen: fix namespaced classes with base/derived in the root NS. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=07a027fac66e5ab77a31016336e89568a2248679;p=blog.git doxygen: fix namespaced classes with base/derived in the root NS. Boom. Interesting, no project until now hit this particular case. --- diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index b4b8d9cb..0a0b117e 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -2675,7 +2675,7 @@ def parse_xml(state: State, xml: str): class_ = Empty() class_.kind = symbol.kind class_.url = symbol.url - class_.name = symbol.leaf_name if state.compounds[compound.id].parent and symbol.parent.startswith(state.compounds[compound.id].parent) else symbol.name + class_.name = symbol.leaf_name if state.compounds[compound.id].parent and symbol.parent and symbol.parent.startswith(state.compounds[compound.id].parent) else symbol.name class_.brief = symbol.brief class_.templates = symbol.templates class_.is_deprecated = symbol.is_deprecated @@ -2698,7 +2698,7 @@ def parse_xml(state: State, xml: str): class_ = Empty() class_.kind = symbol.kind class_.url = symbol.url - class_.name = symbol.leaf_name if state.compounds[compound.id].parent and symbol.parent.startswith(state.compounds[compound.id].parent) else symbol.name + class_.name = symbol.leaf_name if state.compounds[compound.id].parent and symbol.parent and symbol.parent.startswith(state.compounds[compound.id].parent) else symbol.name class_.brief = symbol.brief class_.templates = symbol.templates class_.is_deprecated = symbol.is_deprecated diff --git a/doxygen/test/compound_base_derived_in_root_namespace/Doxyfile b/doxygen/test/compound_base_derived_in_root_namespace/Doxyfile new file mode 100644 index 00000000..443f28ae --- /dev/null +++ b/doxygen/test/compound_base_derived_in_root_namespace/Doxyfile @@ -0,0 +1,14 @@ +INPUT = File.h +QUIET = YES +GENERATE_HTML = NO +GENERATE_LATEX = NO +GENERATE_XML = YES +XML_PROGRAMLISTING = NO +SHOW_INCLUDE_FILES = NO + +##! M_PAGE_FINE_PRINT = +##! M_THEME_COLOR = +##! M_FAVICON = +##! M_LINKS_NAVBAR1 = +##! M_LINKS_NAVBAR2 = +##! M_SEARCH_DISABLED = YES diff --git a/doxygen/test/compound_base_derived_in_root_namespace/File.h b/doxygen/test/compound_base_derived_in_root_namespace/File.h new file mode 100644 index 00000000..79fde603 --- /dev/null +++ b/doxygen/test/compound_base_derived_in_root_namespace/File.h @@ -0,0 +1,17 @@ +/** @file + * @brief The file + */ + +/** @brief A base class in the root namespace */ +struct Base {}; + +/** @brief A namespace */ +namespace Namespace { + +/** @brief A namespaced class with both base and derived in the root NS */ +struct BothBaseAndDerivedInRootNamespace: Base {} + +} + +/** @brief A derived class in the root namespace */ +struct Derived: Namespace::BothBaseAndDerivedInRootNamespace {}; diff --git a/doxygen/test/compound_base_derived_in_root_namespace/structNamespace_1_1BothBaseAndDerivedInRootNamespace.html b/doxygen/test/compound_base_derived_in_root_namespace/structNamespace_1_1BothBaseAndDerivedInRootNamespace.html new file mode 100644 index 00000000..23289fd5 --- /dev/null +++ b/doxygen/test/compound_base_derived_in_root_namespace/structNamespace_1_1BothBaseAndDerivedInRootNamespace.html @@ -0,0 +1,49 @@ + + + + + Namespace::BothBaseAndDerivedInRootNamespace struct | My Project + + + + + +
+
+
+
+
+

+ Namespace::BothBaseAndDerivedInRootNamespace struct +

+

A namespaced class with both base and derived in the root NS.

+
+

Base classes

+
+
+ struct Base +
+
A base class in the root namespace.
+
+
+
+

Derived classes

+
+
+ struct Derived +
+
A derived class in the root namespace.
+
+
+
+
+
+
+ + diff --git a/doxygen/test/test_compound.py b/doxygen/test/test_compound.py index baa80827..9412991d 100644 --- a/doxygen/test/test_compound.py +++ b/doxygen/test/test_compound.py @@ -305,3 +305,13 @@ class IncludesTemplated(IntegrationTestCase): # All entries should have the includes next to the template self.assertEqual(*self.actual_expected_contents('namespaceSpread.html')) self.assertEqual(*self.actual_expected_contents('structStruct.html')) + +class BaseDerivedInRootNamespace(IntegrationTestCase): + def __init__(self, *args, **kwargs): + super().__init__(__file__, 'base_derived_in_root_namespace', *args, **kwargs) + + def test(self): + self.run_dox2html5(wildcard='*.xml') + + # Shouldn't crash or anything + self.assertEqual(*self.actual_expected_contents('structNamespace_1_1BothBaseAndDerivedInRootNamespace.html'))