From: Vladimír Vondruš Date: Mon, 8 Jun 2020 21:06:10 +0000 (+0200) Subject: documentation/doxygen: preserve template info in base classes. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=b5f8f88fe635062f70e0d4a2624cc300d244b1f3;p=blog.git documentation/doxygen: preserve template info in base classes. --- diff --git a/documentation/doxygen.py b/documentation/doxygen.py index 599c85ab..cde5914a 100755 --- a/documentation/doxygen.py +++ b/documentation/doxygen.py @@ -2702,12 +2702,20 @@ def parse_xml(state: State, xml: str): if not compounddef_child.attrib['prot'] == 'private' and id in state.compounds and state.compounds[id].has_details: symbol = state.compounds[id] + # Strip parent if the base class has the same parent as + # this class. Can't just use symbol.leaf_name vs + # symbol.name because the can contain + # template information. + symbol_name = fix_type_spacing(html.escape(compounddef_child.text)) + if state.compounds[compound.id].parent and symbol.parent and symbol.parent.startswith(state.compounds[compound.id].parent): + parent_name = state.compounds[symbol.parent].name + '::' + if symbol_name.startswith(parent_name): + symbol_name = symbol_name[len(parent_name):] + class_ = Empty() class_.kind = symbol.kind class_.url = symbol.url - # Use only the leaf name if the base class has the same - # parent as this class - 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_.name = symbol_name class_.brief = symbol.brief class_.templates = symbol.templates class_.deprecated = symbol.deprecated diff --git a/documentation/test_doxygen/compound_base_template_classes/Doxyfile b/documentation/test_doxygen/compound_base_template_classes/Doxyfile new file mode 100644 index 00000000..7e9ad922 --- /dev/null +++ b/documentation/test_doxygen/compound_base_template_classes/Doxyfile @@ -0,0 +1,14 @@ +INPUT = File.h +QUIET = YES +GENERATE_HTML = NO +GENERATE_LATEX = NO +GENERATE_XML = YES +XML_PROGRAMLISTING = NO +CASE_SENSE_NAMES = YES + +##! M_PAGE_FINE_PRINT = +##! M_THEME_COLOR = +##! M_FAVICON = +##! M_LINKS_NAVBAR1 = +##! M_LINKS_NAVBAR2 = +##! M_SEARCH_DISABLED = YES diff --git a/documentation/test_doxygen/compound_base_template_classes/File.h b/documentation/test_doxygen/compound_base_template_classes/File.h new file mode 100644 index 00000000..e2e7506f --- /dev/null +++ b/documentation/test_doxygen/compound_base_template_classes/File.h @@ -0,0 +1,18 @@ +/** @file + * @brief A file + */ + +/** @brief A namespace */ +namespace Namespace { + +/** @brief A base */ +template struct Base {}; + +/** +@brief A class with two different template bases + +The @ref Namespace gets stripped from the references. +*/ +struct MyClass: Base, Base> {}; + +} diff --git a/documentation/test_doxygen/compound_base_template_classes/structNamespace_1_1MyClass.html b/documentation/test_doxygen/compound_base_template_classes/structNamespace_1_1MyClass.html new file mode 100644 index 00000000..8dbe5821 --- /dev/null +++ b/documentation/test_doxygen/compound_base_template_classes/structNamespace_1_1MyClass.html @@ -0,0 +1,48 @@ + + + + + Namespace::MyClass struct | My Project + + + + + +
+
+ + diff --git a/documentation/test_doxygen/test_compound.py b/documentation/test_doxygen/test_compound.py index 870542cc..efcd7d1b 100644 --- a/documentation/test_doxygen/test_compound.py +++ b/documentation/test_doxygen/test_compound.py @@ -314,3 +314,8 @@ class ExceptionReference(IntegrationTestCase): def test(self): self.run_doxygen(wildcard='*.xml') self.assertEqual(*self.actual_expected_contents('File_8h.html')) + +class BaseTemplateClasses(IntegrationTestCase): + def test(self): + self.run_doxygen(wildcard='*.xml') + self.assertEqual(*self.actual_expected_contents('structNamespace_1_1MyClass.html'))