From: Vladimír Vondruš Date: Sat, 10 Feb 2018 15:58:46 +0000 (+0100) Subject: doxygen: properly qualify base/derived classes in other namespaces. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=cd44d88846fb9ed7ca1ba0ca020eb334fca2ab10;p=blog.git doxygen: properly qualify base/derived classes in other namespaces. Previously the prefix was unconditionally omitted, which is confusing in case a class from one namespace derives from a classs in another namespace. --- diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index 894018a5..5096a7a5 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -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 diff --git a/doxygen/test/cpp_derived/classProtectedBase.html b/doxygen/test/cpp_derived/classAnother_1_1ProtectedBase.html similarity index 73% rename from doxygen/test/cpp_derived/classProtectedBase.html rename to doxygen/test/cpp_derived/classAnother_1_1ProtectedBase.html index 13b7907f..a8620f0c 100644 --- a/doxygen/test/cpp_derived/classProtectedBase.html +++ b/doxygen/test/cpp_derived/classAnother_1_1ProtectedBase.html @@ -2,7 +2,7 @@ - ProtectedBase class | My Project + Another::ProtectedBase class | My Project @@ -20,14 +20,14 @@

- ProtectedBase class + Another::ProtectedBase class

-

Protected base, should list a derived, but w/o any label.

+

Protected base, should list a fully-qualified derived, but w/o any label.

Derived classes

- class A + class Namespace::A
A class.
diff --git a/doxygen/test/cpp_derived/classA.html b/doxygen/test/cpp_derived/classNamespace_1_1A.html similarity index 58% rename from doxygen/test/cpp_derived/classA.html rename to doxygen/test/cpp_derived/classNamespace_1_1A.html index 521bd212..7cd83ff2 100644 --- a/doxygen/test/cpp_derived/classA.html +++ b/doxygen/test/cpp_derived/classNamespace_1_1A.html @@ -2,7 +2,7 @@ - A class | My Project + Namespace::A class | My Project @@ -20,28 +20,28 @@

- A class + Namespace::A class

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).

Base classes

- class ProtectedBase protected + class Another::ProtectedBase protected
-
Protected base, should list a derived, but w/o any label.
+
Protected base, should list a fully-qualified derived, but w/o any label.
- class VirtualBase virtual + class VirtualBase virtual
-
Virtual base, should list a derived, but w/o any label.
+
Virtual base, should list a derived (omitting the common namespace), but w/o any label.

Derived classes

- class Derived + class Another::Derived
A derived class.
diff --git a/doxygen/test/cpp_derived/classPrivateBase.html b/doxygen/test/cpp_derived/classNamespace_1_1PrivateBase.html similarity index 81% rename from doxygen/test/cpp_derived/classPrivateBase.html rename to doxygen/test/cpp_derived/classNamespace_1_1PrivateBase.html index f4ae09e2..710b9f72 100644 --- a/doxygen/test/cpp_derived/classPrivateBase.html +++ b/doxygen/test/cpp_derived/classNamespace_1_1PrivateBase.html @@ -2,7 +2,7 @@ - PrivateBase class | My Project + Namespace::PrivateBase class | My Project @@ -20,7 +20,7 @@

- PrivateBase class + Namespace::PrivateBase class

Private base class, should not list any derived.

diff --git a/doxygen/test/cpp_derived/classVirtualBase.html b/doxygen/test/cpp_derived/classNamespace_1_1VirtualBase.html similarity index 73% rename from doxygen/test/cpp_derived/classVirtualBase.html rename to doxygen/test/cpp_derived/classNamespace_1_1VirtualBase.html index 549fd31c..a4148972 100644 --- a/doxygen/test/cpp_derived/classVirtualBase.html +++ b/doxygen/test/cpp_derived/classNamespace_1_1VirtualBase.html @@ -2,7 +2,7 @@ - VirtualBase class | My Project + Namespace::VirtualBase class | My Project @@ -20,14 +20,14 @@

- VirtualBase class + Namespace::VirtualBase class

-

Virtual base, should list a derived, but w/o any label.

+

Virtual base, should list a derived (omitting the common namespace), but w/o any label.

Derived classes

- class A + class A
A class.
diff --git a/doxygen/test/cpp_derived/input.h b/doxygen/test/cpp_derived/input.h index c9448392..5554104d 100644 --- a/doxygen/test/cpp_derived/input.h +++ b/doxygen/test/cpp_derived/input.h @@ -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 {}; + +} diff --git a/doxygen/test/test_cpp.py b/doxygen/test/test_cpp.py index 006a0830..1b3d6e71 100644 --- a/doxygen/test/test_cpp.py +++ b/doxygen/test/test_cpp.py @@ -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'))