chiark / gitweb /
doxygen: fix namespaced classes with base/derived in the root NS.
authorVladimír Vondruš <mosra@centrum.cz>
Fri, 29 Mar 2019 18:07:40 +0000 (19:07 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Fri, 29 Mar 2019 18:14:20 +0000 (19:14 +0100)
Boom. Interesting, no project until now hit this particular case.

doxygen/dox2html5.py
doxygen/test/compound_base_derived_in_root_namespace/Doxyfile [new file with mode: 0644]
doxygen/test/compound_base_derived_in_root_namespace/File.h [new file with mode: 0644]
doxygen/test/compound_base_derived_in_root_namespace/structNamespace_1_1BothBaseAndDerivedInRootNamespace.html [new file with mode: 0644]
doxygen/test/test_compound.py

index b4b8d9cb63c1795bb2e4f07ca3fa813518d28a7e..0a0b117ee16b876ddba93f70412a502d852c4a22 100755 (executable)
@@ -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 (file)
index 0000000..443f28a
--- /dev/null
@@ -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 (file)
index 0000000..79fde60
--- /dev/null
@@ -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 (file)
index 0000000..23289fd
--- /dev/null
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8" />
+  <title>Namespace::BothBaseAndDerivedInRootNamespace struct | 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-8 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>
+          <span class="m-breadcrumb"><a href="namespaceNamespace.html">Namespace</a>::<wbr/></span>BothBaseAndDerivedInRootNamespace <span class="m-thin">struct</span>
+        </h1>
+        <p>A namespaced class with both base and derived in the root NS.</p>
+        <section id="base-classes">
+          <h2><a href="#base-classes">Base classes</a></h2>
+          <dl class="m-dox">
+            <dt>
+              struct <a href="structBase.html" class="m-dox">Base</a>
+            </dt>
+            <dd>A base class in the root namespace.</dd>
+          </dl>
+        </section>
+        <section id="derived-classes">
+          <h2><a href="#derived-classes">Derived classes</a></h2>
+          <dl class="m-dox">
+            <dt>
+              struct <a href="structDerived.html" class="m-dox">Derived</a>
+            </dt>
+            <dd>A derived class in the root namespace.</dd>
+          </dl>
+        </section>
+      </div>
+    </div>
+  </div>
+</article></main>
+</body>
+</html>
index baa80827a2ead2f6d9a1f18384aba03620341966..9412991d1328a52d0f4697807b9c271f26e22e23 100644 (file)
@@ -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'))