From 193ab8059f56d0ae3dd470fe3dc180d460878151 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 22 Feb 2019 23:58:59 +0100 Subject: [PATCH] doxygen: it gets extra shitty when encountering decltype(auto). Seriously, is the parser a box full of angry monkeys?! How is this possible. --- doxygen/dox2html5.py | 6 +++++ doxygen/test/cpp_function_attributes/input.h | 16 ++++++++++++++ .../cpp_function_attributes/structFoo.html | 22 +++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index b59d8e1f..804d95fa 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -1849,6 +1849,12 @@ def parse_func(state: State, element: ET.Element): elif func.type.startswith('constexpr'): func.type = func.type[10:] func.is_constexpr = True + # For some effing reason, when a constexpr function has decltype(auto) + # return type, Doxygen swaps the order of those two, causing the constexpr + # to be last. See the cpp_function_attributes test for a verification. + elif func.type.endswith('constexpr'): + func.type = func.type[:-10] + func.is_constexpr = True else: func.is_constexpr = False func.prefix = '' diff --git a/doxygen/test/cpp_function_attributes/input.h b/doxygen/test/cpp_function_attributes/input.h index 2d97756e..76ef644a 100644 --- a/doxygen/test/cpp_function_attributes/input.h +++ b/doxygen/test/cpp_function_attributes/input.h @@ -29,6 +29,22 @@ struct Foo { * Details. */ virtual void foo() const noexcept(false) = 0; + + /** + * @brief Random type and constexpr together + * + * This is okay. + */ + constexpr Foo& bar() noexcept; + + /** + * @brief decltype(auto) and constexpr together + * + * For some reason, due to decltype(auto), Doxygen swaps the order, causing + * the constexpr to be hard to detect. Don't even ask how it handles + * trailing return types. It's just HORRIBLE. + */ + constexpr decltype(auto) baz() noexcept; }; /** @brief Base class */ diff --git a/doxygen/test/cpp_function_attributes/structFoo.html b/doxygen/test/cpp_function_attributes/structFoo.html index 3012f95d..566e5e37 100644 --- a/doxygen/test/cpp_function_attributes/structFoo.html +++ b/doxygen/test/cpp_function_attributes/structFoo.html @@ -59,6 +59,14 @@ void foo() const pure virtual noexcept(…)
Const, conditional noexcept and a pure virtual.
+
+ auto bar() -> Foo& constexpr noexcept +
+
Random type and constexpr together.
+
+ auto baz() -> decltype(auto) constexpr noexcept +
+
decltype(auto) and constexpr together
@@ -91,6 +99,20 @@

Const, conditional noexcept and a pure virtual.

Details.

+
+

+ Foo& Foo::bar() constexpr noexcept +

+

Random type and constexpr together.

+

This is okay.

+
+
+

+ decltype(auto) Foo::baz() constexpr noexcept +

+

decltype(auto) and constexpr together

+

For some reason, due to decltype(auto), Doxygen swaps the order, causing the constexpr to be hard to detect. Don't even ask how it handles trailing return types. It's just HORRIBLE.

+
-- 2.30.2