Skip to content

Commit 07c9c87

Browse files
committed
[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.
1 parent 90a202f commit 07c9c87

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

clang-tools-extra/test/clang-doc/Inputs/basic-project/include/Calculator.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,25 @@ class Calculator {
4343
* @throw std::invalid_argument if b is zero.
4444
*/
4545
double divide(int a, int b);
46-
};
46+
47+
/**
48+
* @brief Performs the mod operation on integers.
49+
*
50+
* @param a First integer.
51+
* @param b Second integer.
52+
* @return The result of a % b.
53+
*/
54+
static int mod(int a, int b) {
55+
return a % b;
56+
}
57+
58+
/**
59+
* @brief A static value.
60+
*/
61+
static constexpr int static_val = 10;
62+
63+
/**
64+
* @brief Holds a public value.
65+
*/
66+
int public_val = -1;
67+
};

clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ int Calculator::multiply(int a, int b) {
1515
double Calculator::divide(int a, int b) {
1616
return static_cast<double>(a) / b;
1717
}
18+

clang-tools-extra/test/clang-doc/basic-project.test

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@
129129
// HTML-CALC: <div>brief</div>
130130
// HTML-CALC: <p> A simple calculator class.</p>
131131
// HTML-CALC: <p> Provides basic arithmetic operations.</p>
132+
133+
// HTML-CALC: <h2 id="Members">Members</h2>
134+
// HTML-CALC: <div>brief</div>
135+
// HTML-CALC: <p> Holds a public value.</p>
136+
// HTML-CALC: <div>public int public_val</div>
137+
132138
// HTML-CALC: <h2 id="Functions">Functions</h2>
133139
// HTML-CALC: <h3 id="{{([0-9A-F]{40})}}">add</h3>
134140
// HTML-CALC: <p>public int add(int a, int b)</p>
@@ -185,6 +191,18 @@
185191
// HTML-CALC: <div>throw</div>
186192
// HTML-CALC: <p>if b is zero.</p>
187193

194+
// HTML-CALC: <p>public int mod(int a, int b)</p>
195+
// CALC-NO-REPOSITORY: Defined at line 20 of file .{{.}}src{{.}}Calculator.cpp
196+
// CALC-REPOSITORY: Defined at line
197+
// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp#20">20</a>
198+
// CALC-LINE-PREFIX: <a href="https://repository.com/./src/Calculator.cpp#L20">20</a>
199+
// CALC-REPOSITORY-NEXT: of file
200+
// CALC-REPOSITORY-NEXT: <a href="https://repository.com/./src/Calculator.cpp">Calculator.cpp</a>
201+
// HTML-CALC: <div>brief</div>
202+
// HTML-CALC: <p> Performs the mod operation on integers.</p>
203+
// HTML-CALC: <div>return</div>
204+
// HTML-CALC: <p> The result of a % b.</p>
205+
188206
// HTML-RECTANGLE: <h1>class Rectangle</h1>
189207
// RECTANGLE-NO-REPOSITORY: <p>Defined at line 10 of file .{{.}}include{{.}}Rectangle.h</p>
190208
// RECTANGLE-REPOSITORY: <p>

0 commit comments

Comments
 (0)