From: Vladimír Vondruš Date: Fri, 13 Sep 2024 22:16:34 +0000 (+0200) Subject: documentation/doxygen: remove static keyword from variable types as well. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=53ac5a6b1a4951282b5cde6a3a8c4813bed9adbe;p=blog.git documentation/doxygen: remove static keyword from variable types as well. Like was done in a74bdefc58a34b8054e61e84b480ad6cf0105ad2 for functions. I didn't notice until now, but Doxygen 1.11 finally fixed that, which uncovered the mistake in the test_compound.Listing test. --- diff --git a/documentation/doxygen.py b/documentation/doxygen.py index 025dfaf4..9a88dcea 100755 --- a/documentation/doxygen.py +++ b/documentation/doxygen.py @@ -2228,6 +2228,12 @@ def parse_var(state: State, element: ET.Element): var.is_constexpr = True else: var.is_constexpr = False + # When 1.8.18 encounters `constexpr static`, it keeps the static there. For + # `static constexpr` it doesn't. In both cases the static="yes" is put + # there correctly. Same case is for functions, although there it's further + # complicated with other possible keyword combinations. Fixed in 1.11. + if var.type.startswith('static'): + var.type = var.type[7:] var.is_static = element.attrib['static'] == 'yes' var.is_protected = element.attrib['prot'] == 'protected' var.is_private = element.attrib['prot'] == 'private' diff --git a/documentation/test_doxygen/compound_listing/classRoot_1_1Directory_1_1Sub_1_1Class.html b/documentation/test_doxygen/compound_listing/classRoot_1_1Directory_1_1Sub_1_1Class.html index 46c72740..28afc01b 100644 --- a/documentation/test_doxygen/compound_listing/classRoot_1_1Directory_1_1Sub_1_1Class.html +++ b/documentation/test_doxygen/compound_listing/classRoot_1_1Directory_1_1Sub_1_1Class.html @@ -99,7 +99,7 @@

Public static variables

- static static int Size constexpr + static int Size constexpr
A public static var.
diff --git a/documentation/test_doxygen/cpp_function_attributes/Doxyfile b/documentation/test_doxygen/cpp_function_variable_attributes/Doxyfile similarity index 100% rename from documentation/test_doxygen/cpp_function_attributes/Doxyfile rename to documentation/test_doxygen/cpp_function_variable_attributes/Doxyfile diff --git a/documentation/test_doxygen/cpp_function_attributes/classBase.html b/documentation/test_doxygen/cpp_function_variable_attributes/classBase.html similarity index 100% rename from documentation/test_doxygen/cpp_function_attributes/classBase.html rename to documentation/test_doxygen/cpp_function_variable_attributes/classBase.html diff --git a/documentation/test_doxygen/cpp_function_attributes/classDerived.html b/documentation/test_doxygen/cpp_function_variable_attributes/classDerived.html similarity index 100% rename from documentation/test_doxygen/cpp_function_attributes/classDerived.html rename to documentation/test_doxygen/cpp_function_variable_attributes/classDerived.html diff --git a/documentation/test_doxygen/cpp_function_attributes/input.h b/documentation/test_doxygen/cpp_function_variable_attributes/input.h similarity index 89% rename from documentation/test_doxygen/cpp_function_attributes/input.h rename to documentation/test_doxygen/cpp_function_variable_attributes/input.h index 056ffa7f..db5a5e7f 100644 --- a/documentation/test_doxygen/cpp_function_attributes/input.h +++ b/documentation/test_doxygen/cpp_function_variable_attributes/input.h @@ -10,6 +10,14 @@ struct Foo { */ constexpr static int constexprStaticFunction(); + /** + * @brief Constexpr before static, a variable + * + * 1.8.18 again puts both `constexpr` and `static` into the return type so + * I have to remove them. + */ + constexpr static int ConstexprStaticVariable = 0; + /** * @brief Consteval before static * @@ -24,6 +32,13 @@ struct Foo { */ static constexpr int staticConstexprFunction(); + /** + * @brief Constexpr after static, a variable + * + * Here `static` is not in the type either. + */ + static constexpr int StaticConstexprVariable = 0; + /** * @brief Consteval after static * diff --git a/documentation/test_doxygen/cpp_function_attributes/structFinal.html b/documentation/test_doxygen/cpp_function_variable_attributes/structFinal.html similarity index 100% rename from documentation/test_doxygen/cpp_function_attributes/structFinal.html rename to documentation/test_doxygen/cpp_function_variable_attributes/structFinal.html diff --git a/documentation/test_doxygen/cpp_function_attributes/structFoo.html b/documentation/test_doxygen/cpp_function_variable_attributes/structFoo.html similarity index 86% rename from documentation/test_doxygen/cpp_function_attributes/structFoo.html rename to documentation/test_doxygen/cpp_function_variable_attributes/structFoo.html index 2701acd5..848ce6a0 100644 --- a/documentation/test_doxygen/cpp_function_attributes/structFoo.html +++ b/documentation/test_doxygen/cpp_function_variable_attributes/structFoo.html @@ -29,6 +29,7 @@
  • Reference +
    +

    Public static variables

    +
    +
    + static int ConstexprStaticVariable constexpr +
    +
    Constexpr before static, a variable.
    +
    + static int StaticConstexprVariable constexpr +
    +
    Constexpr after static, a variable.
    +
    +

    Public static functions

    @@ -164,6 +178,23 @@

    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.

    +
    +

    Variable documentation

    +
    +

    + static int Foo::ConstexprStaticVariable constexpr +

    +

    Constexpr before static, a variable.

    +

    1.8.18 again puts both constexpr and static into the return type so I have to remove them.

    +
    +
    +

    + static int Foo::StaticConstexprVariable constexpr +

    +

    Constexpr after static, a variable.

    +

    Here static is not in the type either.

    +
    +
    diff --git a/documentation/test_doxygen/test_cpp.py b/documentation/test_doxygen/test_cpp.py index 52dd64f5..876060e4 100644 --- a/documentation/test_doxygen/test_cpp.py +++ b/documentation/test_doxygen/test_cpp.py @@ -83,7 +83,7 @@ class VariableTemplate(IntegrationTestCase): self.assertEqual(*self.actual_expected_contents('structFoo.html')) self.assertEqual(*self.actual_expected_contents('structBar.html')) -class FunctionAttributes(IntegrationTestCase): +class FunctionVariableAttributes(IntegrationTestCase): def test(self): self.run_doxygen(wildcard='*.xml') self.assertEqual(*self.actual_expected_contents('structFoo.html'))