https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/135456
>From 07c9c8756b564198c2761e353b1b2b2031c9a4ee Mon Sep 17 00:00:00 2001 From: Paul Kirth <paulki...@google.com> Date: Wed, 2 Apr 2025 09:11:20 -0700 Subject: [PATCH 1/3] [clang-doc] Pre-commit tests for static members and functions Issue #59813 mentions that static members are not included in the documentation generated by clang-doc. This patch adds some basic testing for that property, with the current incorrect behavior. Follow up patches will address the missing documentation. --- .../Inputs/basic-project/include/Calculator.h | 23 ++++++++++++++++++- .../Inputs/basic-project/src/Calculator.cpp | 1 + .../test/clang-doc/basic-project.test | 18 +++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/test/clang-doc/Inputs/basic-project/include/Calculator.h b/clang-tools-extra/test/clang-doc/Inputs/basic-project/include/Calculator.h index 6811834bc0159..195721d56fff6 100644 --- a/clang-tools-extra/test/clang-doc/Inputs/basic-project/include/Calculator.h +++ b/clang-tools-extra/test/clang-doc/Inputs/basic-project/include/Calculator.h @@ -43,4 +43,25 @@ class Calculator { * @throw std::invalid_argument if b is zero. */ double divide(int a, int b); -}; \ No newline at end of file + + /** + * @brief Performs the mod operation on integers. + * + * @param a First integer. + * @param b Second integer. + * @return The result of a % b. + */ + static int mod(int a, int b) { + return a % b; + } + + /** + * @brief A static value. + */ + static constexpr int static_val = 10; + + /** + * @brief Holds a public value. + */ + int public_val = -1; +}; diff --git a/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp b/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp index 258ea22e46184..483d050e3225a 100644 --- a/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp +++ b/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp @@ -15,3 +15,4 @@ int Calculator::multiply(int a, int b) { double Calculator::divide(int a, int b) { return static_cast<double>(a) / b; } + diff --git a/clang-tools-extra/test/clang-doc/basic-project.test b/clang-tools-extra/test/clang-doc/basic-project.test index ef26e5b8916b4..822c93a4b2fc0 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.test +++ b/clang-tools-extra/test/clang-doc/basic-project.test @@ -129,6 +129,12 @@ // HTML-CALC: <div>brief</div> // HTML-CALC: <p> A simple calculator class.</p> // HTML-CALC: <p> Provides basic arithmetic operations.</p> + +// HTML-CALC: <h2 id="Members">Members</h2> +// HTML-CALC: <div>brief</div> +// HTML-CALC: <p> Holds a public value.</p> +// HTML-CALC: <div>public int public_val</div> + // HTML-CALC: <h2 id="Functions">Functions</h2> // HTML-CALC: <h3 id="{{([0-9A-F]{40})}}">add</h3> // HTML-CALC: <p>public int add(int a, int b)</p> @@ -185,6 +191,18 @@ // HTML-CALC: <div>throw</div> // HTML-CALC: <p>if b is zero.</p> +// HTML-CALC: <p>public int mod(int a, int b)</p> +// CALC-NO-REPOSITORY: Defined at line 20 of file .{{.}}src{{.}}Calculator.cpp +// CALC-REPOSITORY: Defined at line +// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp#20">20</a> +// CALC-LINE-PREFIX: <a href="https://repository.com/./src/Calculator.cpp#L20">20</a> +// CALC-REPOSITORY-NEXT: of file +// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp">Calculator.cpp</a> +// HTML-CALC: <div>brief</div> +// HTML-CALC: <p> Performs the mod operation on integers.</p> +// HTML-CALC: <div>return</div> +// HTML-CALC: <p> The result of a % b.</p> + // HTML-RECTANGLE: <h1>class Rectangle</h1> // RECTANGLE-NO-REPOSITORY: <p>Defined at line 10 of file .{{.}}include{{.}}Rectangle.h</p> // RECTANGLE-REPOSITORY: <p> >From 512a49d370e353285c54a6ea441bd5394ac67f68 Mon Sep 17 00:00:00 2001 From: Paul Kirth <paulki...@google.com> Date: Fri, 11 Apr 2025 22:02:20 -0700 Subject: [PATCH 2/3] Fix file location in test checks --- clang-tools-extra/test/clang-doc/basic-project.test | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/test/clang-doc/basic-project.test b/clang-tools-extra/test/clang-doc/basic-project.test index 822c93a4b2fc0..6b6d512329c30 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.test +++ b/clang-tools-extra/test/clang-doc/basic-project.test @@ -192,12 +192,12 @@ // HTML-CALC: <p>if b is zero.</p> // HTML-CALC: <p>public int mod(int a, int b)</p> -// CALC-NO-REPOSITORY: Defined at line 20 of file .{{.}}src{{.}}Calculator.cpp +// CALC-NO-REPOSITORY: Defined at line 54 of file .{{.}}include{{.}}Calculator.h // CALC-REPOSITORY: Defined at line -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp#20">20</a> -// CALC-LINE-PREFIX: <a href="https://repository.com/./src/Calculator.cpp#L20">20</a> +// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./include/Calculator.h#54">54</a> +// CALC-LINE-PREFIX: <a href="https://repository.com/./include/Calculator.h#L54">54</a> // CALC-REPOSITORY-NEXT: of file -// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp">Calculator.cpp</a> +// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./include/Calculator.h">Calculator.h</a> // HTML-CALC: <div>brief</div> // HTML-CALC: <p> Performs the mod operation on integers.</p> // HTML-CALC: <div>return</div> >From 05b08107015df686a1de48e59db7586d4fd76e66 Mon Sep 17 00:00:00 2001 From: Paul Kirth <paulki...@google.com> Date: Sat, 12 Apr 2025 10:27:37 -0700 Subject: [PATCH 3/3] Add missing checks for Markdown --- clang-tools-extra/test/clang-doc/basic-project.test | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/clang-tools-extra/test/clang-doc/basic-project.test b/clang-tools-extra/test/clang-doc/basic-project.test index 6b6d512329c30..94484b393df59 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.test +++ b/clang-tools-extra/test/clang-doc/basic-project.test @@ -324,6 +324,8 @@ // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8* // MD-CALC: **brief** A simple calculator class. // MD-CALC: Provides basic arithmetic operations. +// MD-CALC: ## Members +// MD-CALC: public int public_val // MD-CALC: ## Functions // MD-CALC: ### add // MD-CALC: *public int add(int a, int b)* @@ -354,6 +356,13 @@ // MD-CALC: **b** Second integer. // MD-CALC: **return** double The result of a / b. // MD-CALC: **throw**if b is zero. +// MD-CALC: ### mod +// MD-CALC: *public int mod(int a, int b)* +// MD-CALC: *Defined at ./include{{[\/]}}Calculator.h#54* +// MD-CALC: **brief** Performs the mod operation on integers. +// MD-CALC: **a** First integer. +// MD-CALC: **b** Second integer. +// MD-CALC: **return** The result of a % b. // MD-CIRCLE: # class Circle // MD-CIRCLE: *Defined at .{{[\/]}}include{{[\/]}}Circle.h#10* _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits