From cc037a2a57622507d4fa9a0b7ed4f6bd57bfc352 Mon Sep 17 00:00:00 2001 From: Tristan Carel Date: Fri, 15 Mar 2019 10:52:36 +0100 Subject: [PATCH] Remove spurious "typedef" in type declaration when using "using" Remove the spurious "typedef " on right hand side added by Doxygen observed when type is declared inside a namespace See examples/specific/using_in_ns ```cpp // // When declaring a type using a "using" directive inside a namespace, // Doxygen adds a spurious "typedef" in the corresponding XML definition // // $ doxygen --version // 1.8.11 // namespace foo { using foo_int = int; // using foo::foo_int = typedef int } using global_int = int; // using global_int = int ``` It fixes warnings issued by Sphinx when processing the docstring: ``` /path/to/using_in_ns.rst:10: WARNING: Error in type declaration. If typedef-like declaration: Type must be either just a name or a typedef-like declaration. If just a name: Invalid definition: Expected end of definition. [error at 19] foo::foo_int = typedef int ``` * The extra "typedef" has been observed in XML written by Doxygen 1.8.11 * The warning above has been observed with Sphinx 1.8.5 --- breathe/renderer/sphinxrenderer.py | 4 ++++ examples/specific/using_in_ns.cfg | 11 +++++++++++ examples/specific/using_in_ns.h | 13 +++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 examples/specific/using_in_ns.cfg create mode 100644 examples/specific/using_in_ns.h diff --git a/breathe/renderer/sphinxrenderer.py b/breathe/renderer/sphinxrenderer.py index 9ac22d5e..5bc64b43 100644 --- a/breathe/renderer/sphinxrenderer.py +++ b/breathe/renderer/sphinxrenderer.py @@ -1060,6 +1060,10 @@ def visit_typedef(self, node): declaration = declaration[len(typedef):] elif declaration.startswith(using): declaration = declaration[len(using):] + # remove the spurious "typedef " on right hand side added + # by Doxygen observed when type is declared inside a namespace + # See examples/specific/using_in_ns + declaration = declaration.replace(" = typedef ", " = ") obj_type = "using" def update_signature(signature, obj_type): diff --git a/examples/specific/using_in_ns.cfg b/examples/specific/using_in_ns.cfg new file mode 100644 index 00000000..1fca15d1 --- /dev/null +++ b/examples/specific/using_in_ns.cfg @@ -0,0 +1,11 @@ +PROJECT_NAME = "UsingInNS" +OUTPUT_DIRECTORY = using_in_ns +GENERATE_LATEX = NO +GENERATE_MAN = NO +GENERATE_RTF = NO +CASE_SENSE_NAMES = NO +INPUT = using_in_ns.h +QUIET = YES +JAVADOC_AUTOBRIEF = YES +GENERATE_HTML = NO +GENERATE_XML = YES diff --git a/examples/specific/using_in_ns.h b/examples/specific/using_in_ns.h new file mode 100644 index 00000000..f19e6c44 --- /dev/null +++ b/examples/specific/using_in_ns.h @@ -0,0 +1,13 @@ +// +// When declaring a type using a "using" directive inside a namespace, +// Doxygen adds a spurious "typedef" in the corresponding XML definition +// +// $ doxygen --version +// 1.8.11 +// + +namespace foo { +using foo_int = int; // using foo::foo_int = typedef int +} + +using global_int = int; // using global_int = int