From: Vladimír Vondruš Date: Fri, 22 Feb 2019 22:58:59 +0000 (+0100) Subject: doxygen: it gets extra shitty when encountering decltype(auto). X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=193ab8059f56d0ae3dd470fe3dc180d460878151;p=blog.git doxygen: it gets extra shitty when encountering decltype(auto). Seriously, is the parser a box full of angry monkeys?! How is this possible. --- 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.

+