chiark / gitweb /
documentation/doxygen: remove static keyword from variable types as well.
authorVladimír Vondruš <mosra@centrum.cz>
Fri, 13 Sep 2024 22:16:34 +0000 (00:16 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 14 Sep 2024 00:46:33 +0000 (02:46 +0200)
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.

documentation/doxygen.py
documentation/test_doxygen/compound_listing/classRoot_1_1Directory_1_1Sub_1_1Class.html
documentation/test_doxygen/cpp_function_variable_attributes/Doxyfile [moved from documentation/test_doxygen/cpp_function_attributes/Doxyfile with 100% similarity]
documentation/test_doxygen/cpp_function_variable_attributes/classBase.html [moved from documentation/test_doxygen/cpp_function_attributes/classBase.html with 100% similarity]
documentation/test_doxygen/cpp_function_variable_attributes/classDerived.html [moved from documentation/test_doxygen/cpp_function_attributes/classDerived.html with 100% similarity]
documentation/test_doxygen/cpp_function_variable_attributes/input.h [moved from documentation/test_doxygen/cpp_function_attributes/input.h with 89% similarity]
documentation/test_doxygen/cpp_function_variable_attributes/structFinal.html [moved from documentation/test_doxygen/cpp_function_attributes/structFinal.html with 100% similarity]
documentation/test_doxygen/cpp_function_variable_attributes/structFoo.html [moved from documentation/test_doxygen/cpp_function_attributes/structFoo.html with 86% similarity]
documentation/test_doxygen/test_cpp.py

index 025dfaf4eff2c913906ddff6316bf9bc0a14c22a..9a88dceaaa9e15b2372151edcb2fac6d09d6b4e3 100755 (executable)
@@ -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'
index 46c727405df7e261fffc023fda49a8c42245153e..28afc01b88db43a6f7c029aa0df4fa5e801ccdec 100644 (file)
@@ -99,7 +99,7 @@
           <h2><a href="#pub-static-attribs">Public static variables</a></h2>
           <dl class="m-doc">
             <dt id="a912d8f1390853f90e0a9f19ec98771e6">
-              static static int <a href="#a912d8f1390853f90e0a9f19ec98771e6" class="m-doc-self">Size</a> <span class="m-label m-flat m-primary">constexpr</span>
+              static int <a href="#a912d8f1390853f90e0a9f19ec98771e6" class="m-doc-self">Size</a> <span class="m-label m-flat m-primary">constexpr</span>
             </dt>
             <dd>A public static var.</dd>
           </dl>
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 056ffa7f1dc22b6b38baaa99560ae9abd59f86d8..db5a5e7f4c6898dbb38d5d9735c755f3f323c7b1 100644 (file)
@@ -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
      *
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 2701acd505cb6c512849b2bb1c7a205b055f4a18..848ce6a060c39a58dc195da96706987797d7f0f2 100644 (file)
@@ -29,6 +29,7 @@
             <li>
               Reference
               <ul>
+                <li><a href="#pub-static-attribs">Public static variables</a></li>
                 <li><a href="#pub-static-methods">Public static functions</a></li>
                 <li><a href="#typeless-methods">Constructors, destructors, conversion operators</a></li>
                 <li><a href="#pub-methods">Public functions</a></li>
             </li>
           </ul>
         </nav>
+        <section id="pub-static-attribs">
+          <h2><a href="#pub-static-attribs">Public static variables</a></h2>
+          <dl class="m-doc">
+            <dt>
+              static int <a href="#a3fca5e0d9720095041dce1c150d3c9f8" class="m-doc">ConstexprStaticVariable</a> <span class="m-label m-flat m-primary">constexpr</span>
+            </dt>
+            <dd>Constexpr before static, a variable.</dd>
+            <dt>
+              static int <a href="#aca521b15a93807423e798f96b1bdde5a" class="m-doc">StaticConstexprVariable</a> <span class="m-label m-flat m-primary">constexpr</span>
+            </dt>
+            <dd>Constexpr after static, a variable.</dd>
+          </dl>
+        </section>
         <section id="pub-static-methods">
           <h2><a href="#pub-static-methods">Public static functions</a></h2>
           <dl class="m-doc">
 <p>For some reason, due to decltype(auto), Doxygen swaps the order, causing the constexpr to be hard to detect. Don&#x27;t even ask how it handles trailing return types. It&#x27;s just HORRIBLE.</p>
           </div></section>
         </section>
+        <section>
+          <h2>Variable documentation</h2>
+          <section class="m-doc-details" id="a3fca5e0d9720095041dce1c150d3c9f8"><div>
+            <h3>
+              static int Foo::<wbr /><a href="#a3fca5e0d9720095041dce1c150d3c9f8" class="m-doc-self">ConstexprStaticVariable</a> <span class="m-label m-primary">constexpr</span>
+            </h3>
+            <p>Constexpr before static, a variable.</p>
+<p>1.8.18 again puts both <code>constexpr</code> and <code>static</code> into the return type so I have to remove them.</p>
+          </div></section>
+          <section class="m-doc-details" id="aca521b15a93807423e798f96b1bdde5a"><div>
+            <h3>
+              static int Foo::<wbr /><a href="#aca521b15a93807423e798f96b1bdde5a" class="m-doc-self">StaticConstexprVariable</a> <span class="m-label m-primary">constexpr</span>
+            </h3>
+            <p>Constexpr after static, a variable.</p>
+<p>Here <code>static</code> is not in the type either.</p>
+          </div></section>
+        </section>
       </div>
     </div>
   </div>
index 52dd64f5b027419ebc789f3af44c850a2964f07a..876060e40b487b53e508f2c7567c8ccc33d2bc17 100644 (file)
@@ -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'))