chiark / gitweb /
doxygen: properly qualify base/derived classes in other namespaces.
authorVladimír Vondruš <mosra@centrum.cz>
Sat, 10 Feb 2018 15:58:46 +0000 (16:58 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 10 Feb 2018 16:32:49 +0000 (17:32 +0100)
Previously the prefix was unconditionally omitted, which is confusing in
case a class from one namespace derives from a classs in another
namespace.

doxygen/dox2html5.py
doxygen/test/cpp_derived/classAnother_1_1ProtectedBase.html [moved from doxygen/test/cpp_derived/classProtectedBase.html with 73% similarity]
doxygen/test/cpp_derived/classNamespace_1_1A.html [moved from doxygen/test/cpp_derived/classA.html with 58% similarity]
doxygen/test/cpp_derived/classNamespace_1_1PrivateBase.html [moved from doxygen/test/cpp_derived/classPrivateBase.html with 81% similarity]
doxygen/test/cpp_derived/classNamespace_1_1VirtualBase.html [moved from doxygen/test/cpp_derived/classVirtualBase.html with 73% similarity]
doxygen/test/cpp_derived/input.h
doxygen/test/test_cpp.py

index 894018a59b9218d1b1a20ce9e8431aba2f41f9d0..5096a7a50452f58baefb13a041e7407ad685d074 100755 (executable)
@@ -2052,7 +2052,7 @@ def parse_xml(state: State, xml: str):
                     class_ = Empty()
                     class_.kind = symbol.kind
                     class_.url = symbol.url
-                    class_.name = symbol.leaf_name
+                    class_.name = symbol.leaf_name if 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
@@ -2075,7 +2075,7 @@ def parse_xml(state: State, xml: str):
                     class_ = Empty()
                     class_.kind = symbol.kind
                     class_.url = symbol.url
-                    class_.name = symbol.leaf_name
+                    class_.name = symbol.leaf_name if 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
similarity index 73%
rename from doxygen/test/cpp_derived/classProtectedBase.html
rename to doxygen/test/cpp_derived/classAnother_1_1ProtectedBase.html
index 13b7907fdc3114ea30b370bb7acbe439e8a0faad..a8620f0c9085979197b6a3c75cdc1d13d6084a95 100644 (file)
@@ -2,7 +2,7 @@
 <html lang="en">
 <head>
   <meta charset="UTF-8" />
-  <title>ProtectedBase class | My Project</title>
+  <title>Another::ProtectedBase class | 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" />
     <div class="m-row">
       <div class="m-col-l-10 m-push-l-1">
         <h1>
-          ProtectedBase <span class="m-thin">class</span>
+          <span class="m-breadcrumb"><a href="namespaceAnother.html">Another</a>::</span>ProtectedBase <span class="m-thin">class</span>
         </h1>
-        <p>Protected base, should list a derived, but w/o any label.</p>
+        <p>Protected base, should list a fully-qualified derived, but w/o any label.</p>
         <section id="derived-classes">
           <h2><a href="#derived-classes">Derived classes</a></h3>
           <dl class="m-dox">
             <dt>
-              class <a href="classA.html" class="m-dox">A</a>
+              class <a href="classNamespace_1_1A.html" class="m-dox">Namespace::A</a>
             </dt>
             <dd>A class.</dd>
           </dl>
similarity index 58%
rename from doxygen/test/cpp_derived/classA.html
rename to doxygen/test/cpp_derived/classNamespace_1_1A.html
index 521bd212c4f8e7d3900a8b5e3bea2aeac31cfb75..7cd83ff2fe022a7636c8a3326a67b7f78bbffaf5 100644 (file)
@@ -2,7 +2,7 @@
 <html lang="en">
 <head>
   <meta charset="UTF-8" />
-  <title>A class | My Project</title>
+  <title>Namespace::A class | 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" />
     <div class="m-row">
       <div class="m-col-l-10 m-push-l-1">
         <h1>
-          A <span class="m-thin">class</span>
+          <span class="m-breadcrumb"><a href="namespaceNamespace.html">Namespace</a>::</span>A <span class="m-thin">class</span>
         </h1>
         <p>A class.</p>
-<p>Should list one protected base and one virtual base, one derived class.</p>
+<p>Should list one protected base (fully qualified) and one virtual base (omitting the common namespace), one derived class (fully qualified).</p>
         <section id="base-classes">
           <h2><a href="#base-classes">Base classes</a></h3>
           <dl class="m-dox">
             <dt>
-              class <a href="classProtectedBase.html" class="m-dox">ProtectedBase</a> <span class="m-label m-flat m-warning">protected</span>
+              class <a href="classAnother_1_1ProtectedBase.html" class="m-dox">Another::ProtectedBase</a> <span class="m-label m-flat m-warning">protected</span>
             </dt>
-            <dd>Protected base, should list a derived, but w/o any label.</dd>
+            <dd>Protected base, should list a fully-qualified derived, but w/o any label.</dd>
             <dt>
-              class <a href="classVirtualBase.html" class="m-dox">VirtualBase</a> <span class="m-label m-flat m-warning">virtual</span>
+              class <a href="classNamespace_1_1VirtualBase.html" class="m-dox">VirtualBase</a> <span class="m-label m-flat m-warning">virtual</span>
             </dt>
-            <dd>Virtual base, should list a derived, but w/o any label.</dd>
+            <dd>Virtual base, should list a derived (omitting the common namespace), but w/o any label.</dd>
           </dl>
         </section>
         <section id="derived-classes">
           <h2><a href="#derived-classes">Derived classes</a></h3>
           <dl class="m-dox">
             <dt>
-              class <a href="classDerived.html" class="m-dox">Derived</a>
+              class <a href="classAnother_1_1Derived.html" class="m-dox">Another::Derived</a>
             </dt>
             <dd>A derived class.</dd>
           </dl>
similarity index 81%
rename from doxygen/test/cpp_derived/classPrivateBase.html
rename to doxygen/test/cpp_derived/classNamespace_1_1PrivateBase.html
index f4ae09e2242a053328386e7e1dafef2849d5dfdd..710b9f721d54793d11b2f31ca5dfe0f99f1ef526 100644 (file)
@@ -2,7 +2,7 @@
 <html lang="en">
 <head>
   <meta charset="UTF-8" />
-  <title>PrivateBase class | My Project</title>
+  <title>Namespace::PrivateBase class | 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" />
@@ -20,7 +20,7 @@
     <div class="m-row">
       <div class="m-col-l-10 m-push-l-1">
         <h1>
-          PrivateBase <span class="m-thin">class</span>
+          <span class="m-breadcrumb"><a href="namespaceNamespace.html">Namespace</a>::</span>PrivateBase <span class="m-thin">class</span>
         </h1>
         <p>Private base class, should not list any derived.</p>
       </div>
similarity index 73%
rename from doxygen/test/cpp_derived/classVirtualBase.html
rename to doxygen/test/cpp_derived/classNamespace_1_1VirtualBase.html
index 549fd31c12db68cc0a4b15f32ece45f892baa9c4..a4148972d0a5aedeae028ac170bec84181bd703f 100644 (file)
@@ -2,7 +2,7 @@
 <html lang="en">
 <head>
   <meta charset="UTF-8" />
-  <title>VirtualBase class | My Project</title>
+  <title>Namespace::VirtualBase class | 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" />
     <div class="m-row">
       <div class="m-col-l-10 m-push-l-1">
         <h1>
-          VirtualBase <span class="m-thin">class</span>
+          <span class="m-breadcrumb"><a href="namespaceNamespace.html">Namespace</a>::</span>VirtualBase <span class="m-thin">class</span>
         </h1>
-        <p>Virtual base, should list a derived, but w/o any label.</p>
+        <p>Virtual base, should list a derived (omitting the common namespace), but w/o any label.</p>
         <section id="derived-classes">
           <h2><a href="#derived-classes">Derived classes</a></h3>
           <dl class="m-dox">
             <dt>
-              class <a href="classA.html" class="m-dox">A</a>
+              class <a href="classNamespace_1_1A.html" class="m-dox">A</a>
             </dt>
             <dd>A class.</dd>
           </dl>
index c9448392a2c075ec4b45ec466c6cbc196bbf0e9d..5554104d461973f881622414bab4880340533d91 100644 (file)
@@ -1,22 +1,43 @@
+namespace Namespace {
+
 /** @brief Private base class, should not list any derived */
 class PrivateBase {};
 
-/** @brief Protected base, should list a derived, but w/o any label */
+}
+
+namespace Another {
+
+/** @brief Protected base, should list a fully-qualified derived, but w/o any label */
 class ProtectedBase {};
 
+}
+
+namespace Namespace {
+
 class UndocumentedBase {};
 
-/** @brief Virtual base, should list a derived, but w/o any label */
+/** @brief Virtual base, should list a derived (omitting the common namespace), but w/o any label */
 class VirtualBase {};
 
 /**
 @brief A class
 
-Should list one protected base and one virtual base, one derived class.
+Should list one protected base (fully qualified) and one virtual base (omitting
+the common namespace), one derived class (fully qualified).
 */
-class A: PrivateBase, protected ProtectedBase, public UndocumentedBase, public virtual VirtualBase {};
+class A: PrivateBase, protected Another::ProtectedBase, public UndocumentedBase, public virtual VirtualBase {};
+
+}
+
+namespace Another {
 
 /** @brief A derived class */
-class Derived: public A {};
+class Derived: public Namespace::A {};
+
+}
+
+namespace Namespace {
 
 struct UndocumentedDerived: A {};
+
+}
index 006a0830cd6884c2618b8071d0d30a3f6826055c..1b3d6e71e602888259b1bef182ee99529431dada 100644 (file)
@@ -55,7 +55,7 @@ class Derived(IntegrationTestCase):
 
     def test(self):
         self.run_dox2html5(wildcard='*.xml')
-        self.assertEqual(*self.actual_expected_contents('classA.html'))
-        self.assertEqual(*self.actual_expected_contents('classPrivateBase.html'))
-        self.assertEqual(*self.actual_expected_contents('classProtectedBase.html'))
-        self.assertEqual(*self.actual_expected_contents('classVirtualBase.html'))
+        self.assertEqual(*self.actual_expected_contents('classNamespace_1_1A.html'))
+        self.assertEqual(*self.actual_expected_contents('classNamespace_1_1PrivateBase.html'))
+        self.assertEqual(*self.actual_expected_contents('classAnother_1_1ProtectedBase.html'))
+        self.assertEqual(*self.actual_expected_contents('classNamespace_1_1VirtualBase.html'))