Skip to content

Commit 6c46972

Browse files
evelez7aadeshps-mcw
authored andcommitted
[clang-doc] Add Mustache HTML output to namespace test (llvm#169107)
This patch adds Mustache HTML tests alongside the legacy HTML backend for namespace output. This way, we can see exactly where the output currently differs before replacing the legacy backend. The same thing will be done for all other tests where the legacy HTML backend is tested.
1 parent 8f5cecc commit 6c46972

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

clang-tools-extra/test/clang-doc/namespace.cpp

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: rm -rf %t && mkdir -p %t
22
// RUN: clang-doc --format=html --output=%t --executor=standalone %s
33
// RUN: clang-doc --format=md --output=%t --executor=standalone %s
4+
// RUN: clang-doc --format=mustache --output=%t --executor=standalone %s
45
// RUN: FileCheck %s < %t/index_json.js -check-prefix=JSON-INDEX
56
// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.html -check-prefix=HTML-ANON-CLASS-LINE
67
// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.html -check-prefix=HTML-ANON-CLASS
@@ -38,19 +39,42 @@
3839
// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-GLOBAL-INDEX
3940
// RUN: FileCheck %s < %t/all_files.md -check-prefix=MD-ALL-FILES
4041
// RUN: FileCheck %s < %t/index.md -check-prefix=MD-INDEX
42+
// RUN: FileCheck %s < %t/html/@nonymous_namespace/_ZTVN12_GLOBAL__N_19AnonClassE.html -check-prefix=MUSTACHE-ANON-CLASS-LINE
43+
// RUN: FileCheck %s < %t/html/@nonymous_namespace/_ZTVN12_GLOBAL__N_19AnonClassE.html -check-prefix=MUSTACHE-ANON-CLASS
44+
// RUN: FileCheck %s < %t/html/@nonymous_namespace/index.html -check-prefix=MUSTACHE-ANON-INDEX-LINE
45+
// RUN: FileCheck %s < %t/html/@nonymous_namespace/index.html -check-prefix=MUSTACHE-ANON-INDEX
46+
// RUN: FileCheck %s < %t/html/AnotherNamespace/_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.html -check-prefix=MUSTACHE-ANOTHER-CLASS-LINE
47+
// RUN: FileCheck %s < %t/html/AnotherNamespace/_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.html -check-prefix=MUSTACHE-ANOTHER-CLASS
48+
// RUN: FileCheck %s < %t/html/AnotherNamespace/index.html -check-prefix=MUSTACHE-ANOTHER-INDEX-LINE
49+
// RUN: FileCheck %s < %t/html/AnotherNamespace/index.html -check-prefix=MUSTACHE-ANOTHER-INDEX
50+
// RUN: FileCheck %s < %t/html/PrimaryNamespace/NestedNamespace/_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.html -check-prefix=MUSTACHE-NESTED-CLASS-LINE
51+
// RUN: FileCheck %s < %t/html/PrimaryNamespace/NestedNamespace/_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.html -check-prefix=MUSTACHE-NESTED-CLASS
52+
// RUN: FileCheck %s < %t/html/PrimaryNamespace/NestedNamespace/index.html -check-prefix=MUSTACHE-NESTED-INDEX-LINE
53+
// RUN: FileCheck %s < %t/html/PrimaryNamespace/NestedNamespace/index.html -check-prefix=MUSTACHE-NESTED-INDEX
54+
// RUN: FileCheck %s < %t/html/PrimaryNamespace/index.html -check-prefix=MUSTACHE-PRIMARY-INDEX-LINE
55+
// RUN: FileCheck %s < %t/html/PrimaryNamespace/index.html -check-prefix=MUSTACHE-PRIMARY-INDEX
56+
// RUN: FileCheck %s < %t/html/PrimaryNamespace/_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.html -check-prefix=MUSTACHE-PRIMARY-CLASS-LINE
57+
// RUN: FileCheck %s < %t/html/PrimaryNamespace/_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.html -check-prefix=MUSTACHE-PRIMARY-CLASS
58+
59+
// COM: FIXME: Add global functions to the namespace template
60+
// COM: FIXME: Add namespaces to the namespace template
61+
// COM: FIXME: Add class definition location to class template
4162

4263
// Anonymous Namespace
4364
namespace {
4465
void anonFunction() {}
4566
// MD-ANON-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
4667
// HTML-ANON-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
68+
// MUSTACHE-ANON-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
4769

4870
class AnonClass {};
4971
// MD-ANON-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
5072
// HTML-ANON-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
73+
// MUSTACHE-ANON-CLASS-LINE-NOT: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
5174

5275
// MD-ANON-CLASS: # class AnonClass
5376
// HTML-ANON-CLASS: <h1>class AnonClass</h1>
77+
// MUSTACHE-ANON-CLASS: <h1 class="hero__title-large">class AnonClass</h1>
5478
} // namespace
5579

5680
// MD-ANON-INDEX: # namespace @nonymous_namespace
@@ -69,41 +93,61 @@ class AnonClass {};
6993
// HTML-ANON-INDEX: <h3 id="{{([0-9A-F]{40})}}">anonFunction</h3>
7094
// HTML-ANON-INDEX: <p>void anonFunction()</p>
7195

96+
// MUSTACHE-ANON-INDEX: <h2> @nonymous_namespace</h2>
97+
// MUSTACHE-ANON-INDEX: <h2>Inner Classes</h2>
98+
// MUSTACHE-ANON-INDEX: <ul class="class-container">
99+
// MUSTACHE-ANON-INDEX: <li id="{{([0-9A-F]{40})}}" style="max-height: 40px;">
100+
// MUSTACHE-ANON-INDEX: <a href="_ZTVN12_GLOBAL__N_19AnonClassE.html">
101+
// MUSTACHE-ANON-INDEX: <pre><code class="language-cpp code-clang-doc">class AnonClass</code></pre>
102+
// MUSTACHE-ANON-INDEX: </a>
103+
// MUSTACHE-ANON-INDEX: </li>
104+
// MUSTACHE-ANON-INDEX-NOT: <h2 id="Functions">Functions</h2>
105+
// MUSTACHE-ANON-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">anonFunction</h3>
106+
// MUSTACHE-ANON-INDEX-NOT: <p>void anonFunction()</p>
107+
72108
// Primary Namespace
73109
namespace PrimaryNamespace {
74110
// Function in PrimaryNamespace
75111
void functionInPrimaryNamespace() {}
76112
// MD-PRIMARY-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
77113
// HTML-PRIMARY-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
114+
// MUSTACHE-PRIMARY-INDEX-LINE-NOT: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
78115

79116
// Class in PrimaryNamespace
80117
class ClassInPrimaryNamespace {};
81118
// MD-PRIMARY-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
82119
// HTML-PRIMARY-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
120+
// MUSTACHE-PRIMARY-CLASS-LINE-NOT: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
83121

84122
// MD-PRIMARY-CLASS: # class ClassInPrimaryNamespace
85123
// MD-PRIMARY-CLASS: Class in PrimaryNamespace
86124

87125
// HTML-PRIMARY-CLASS: <h1>class ClassInPrimaryNamespace</h1>
88126
// HTML-PRIMARY-CLASS: <p> Class in PrimaryNamespace</p>
89127

128+
// MUSTACHE-PRIMARY-CLASS: <h1 class="hero__title-large">class ClassInPrimaryNamespace</h1>
129+
90130
// Nested namespace
91131
namespace NestedNamespace {
92132
// Function in NestedNamespace
93133
void functionInNestedNamespace() {}
94134
// MD-NESTED-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
95135
// HTML-NESTED-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
136+
// MUSTACHE-NESTED-INDEX-LINE-NOT: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
96137

97138
// Class in NestedNamespace
98139
class ClassInNestedNamespace {};
99140
// MD-NESTED-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
100141
// HTML-NESTED-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
142+
// MUSTACHE-NESTED-CLASS-LINE-NOT: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
101143

102144
// MD-NESTED-CLASS: # class ClassInNestedNamespace
103145
// MD-NESTED-CLASS: Class in NestedNamespace
104146

105147
// HTML-NESTED-CLASS: <h1>class ClassInNestedNamespace</h1>
106148
// HTML-NESTED-CLASS: <p> Class in NestedNamespace</p>
149+
150+
// MUSTACHE-NESTED-CLASS: <h1 class="hero__title-large">class ClassInNestedNamespace</h1>
107151
} // namespace NestedNamespace
108152

109153
// MD-NESTED-INDEX: # namespace NestedNamespace
@@ -123,6 +167,20 @@ class ClassInNestedNamespace {};
123167
// HTML-NESTED-INDEX: <h3 id="{{([0-9A-F]{40})}}">functionInNestedNamespace</h3>
124168
// HTML-NESTED-INDEX: <p>void functionInNestedNamespace()</p>
125169
// HTML-NESTED-INDEX: <p> Function in NestedNamespace</p>
170+
171+
// MUSTACHE-NESTED-INDEX: <h2> NestedNamespace</h2>
172+
// MUSTACHE-NESTED-INDEX: <h2>Inner Classes</h2>
173+
// MUSTACHE-NESTED-INDEX: <ul class="class-container">
174+
// MUSTACHE-NESTED-INDEX: <li id="{{([0-9A-F]{40})}}" style="max-height: 40px;">
175+
// MUSTACHE-NESTED-INDEX: <a href="_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.html">
176+
// MUSTACHE-NESTED-INDEX: <pre><code class="language-cpp code-clang-doc">class ClassInNestedNamespace</code></pre>
177+
// MUSTACHE-NESTED-INDEX: </a>
178+
// MUSTACHE-NESTED-INDEX: </li>
179+
// MUSTACHE-NESTED-INDEX: </ul>
180+
// MUSTACHE-NESTED-INDEX-NOT: <h2 id="Functions">Functions</h2>
181+
// MUSTACHE-NESTED-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">functionInNestedNamespace</h3>
182+
// MUSTACHE-NESTED-INDEX-NOT: <p>void functionInNestedNamespace()</p>
183+
// MUSTACHE-NESTED-INDEX-NOT: <p> Function in NestedNamespace</p>
126184
} // namespace PrimaryNamespace
127185

128186
// MD-PRIMARY-INDEX: # namespace PrimaryNamespace
@@ -147,24 +205,44 @@ class ClassInNestedNamespace {};
147205
// HTML-PRIMARY-INDEX: <p>void functionInPrimaryNamespace()</p>
148206
// HTML-PRIMARY-INDEX: <p> Function in PrimaryNamespace</p>
149207

208+
// MUSTACHE-PRIMARY-INDEX: <h2> PrimaryNamespace</h2>
209+
// MUSTACHE-PRIMARY-INDEX-NOT: <h2 id="Namespaces">Namespaces</h2>
210+
// MUSTACHE-PRIMARY-INDEX-NOT: <a href="NestedNamespace{{[\/]}}index.html">NestedNamespace</a>
211+
// MUSTACHE-PRIMARY-INDEX <h2>Inner Classes</h2>
212+
// MUSTACHE-PRIMARY-INDEX <ul class="class-container">
213+
// MUSTACHE-PRIMARY-INDEX <li id="{{([0-9A-F]{40})}}" style="max-height: 40px;">
214+
// MUSTACHE-PRIMARY-INDEX <a href="_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.html">
215+
// MUSTACHE-PRIMARY-INDEX <pre><code class="language-cpp code-clang-doc">class ClassInPrimaryNamespace</code></pre>
216+
// MUSTACHE-PRIMARY-INDEX </a>
217+
// MUSTACHE-PRIMARY-INDEX </li>
218+
// MUSTACHE-PRIMARY-INDEX </ul>
219+
// MUSTACHE-PRIMARY-INDEX-NOT: <h2 id="Functions">Functions</h2>
220+
// MUSTACHE-PRIMARY-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">functionInPrimaryNamespace</h3>
221+
// MUSTACHE-PRIMARY-INDEX-NOT: <p>void functionInPrimaryNamespace()</p>
222+
// MUSTACHE-PRIMARY-INDEX-NOT: <p> Function in PrimaryNamespace</p>
223+
150224
// AnotherNamespace
151225
namespace AnotherNamespace {
152226
// Function in AnotherNamespace
153227
void functionInAnotherNamespace() {}
154228
// MD-ANOTHER-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
155229
// HTML-ANOTHER-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
230+
// MUSTACHE-ANOTHER-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
156231

157232
// Class in AnotherNamespace
158233
class ClassInAnotherNamespace {};
159234
// MD-ANOTHER-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
160235
// HTML-ANOTHER-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
236+
// MUSTACHE-ANOTHER-CLASS-LINE-NOT: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
161237

162238
// MD-ANOTHER-CLASS: # class ClassInAnotherNamespace
163239
// MD-ANOTHER-CLASS: Class in AnotherNamespace
164240

165241
// HTML-ANOTHER-CLASS: <h1>class ClassInAnotherNamespace</h1>
166242
// HTML-ANOTHER-CLASS: <p> Class in AnotherNamespace</p>
167243

244+
// MUSTACHE-ANOTHER-CLASS: <h1 class="hero__title-large">class ClassInAnotherNamespace</h1>
245+
168246
} // namespace AnotherNamespace
169247

170248
// MD-ANOTHER-INDEX: # namespace AnotherNamespace
@@ -185,6 +263,20 @@ class ClassInAnotherNamespace {};
185263
// HTML-ANOTHER-INDEX: <p>void functionInAnotherNamespace()</p>
186264
// HTML-ANOTHER-INDEX: <p> Function in AnotherNamespace</p>
187265

266+
// MUSTACHE-ANOTHER-INDEX: <h2> AnotherNamespace</h2>
267+
// MUSTACHE-ANOTHER-INDEX: <h2>Inner Classes</h2>
268+
// MUSTACHE-ANOTHER-INDEX: <ul class="class-container">
269+
// MUSTACHE-ANOTHER-INDEX: <li id="{{([0-9A-F]{40})}}" style="max-height: 40px;">
270+
// MUSTACHE-ANOTHER-INDEX: <a href="_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.html">
271+
// MUSTACHE-ANOTHER-INDEX: <pre><code class="language-cpp code-clang-doc">class ClassInAnotherNamespace</code></pre>
272+
// MUSTACHE-ANOTHER-INDEX: </a>
273+
// MUSTACHE-ANOTHER-INDEX: </li>
274+
// MUSTACHE-ANOTHER-INDEX: </ul>
275+
// MUSTACHE-ANOTHER-INDEX-NOT: <h2 id="Functions">Functions</h2>
276+
// MUSTACHE-ANOTHER-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">functionInAnotherNamespace</h3>
277+
// MUSTACHE-ANOTHER-INDEX-NOT: <p>void functionInAnotherNamespace()</p>
278+
// MUSTACHE-ANOTHER-INDEX-NOT: <p> Function in AnotherNamespace</p>
279+
188280
// JSON-INDEX: async function LoadIndex() {
189281
// JSON-INDEX-NEXT: return{
190282
// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}",
@@ -270,6 +362,13 @@ class ClassInAnotherNamespace {};
270362
// HTML-GLOBAL-INDEX: <li>AnotherNamespace</li>
271363
// HTML-GLOBAL-INDEX: <li>PrimaryNamespace</li>
272364

365+
// MUSTACHE-GLOBAL-INDEX: <div id="main-content" class="col-xs-12 col-sm-9 col-md-8 main-content">
366+
// MUSTACHE-GLOBAL-INDEX: <h1>Global Namespace</h1>
367+
// MUSTACHE-GLOBAL-INDEX: <h2 id="Namespaces">Namespaces</h2>
368+
// MUSTACHE-GLOBAL-INDEX: <li>@nonymous_namespace</li>
369+
// MUSTACHE-GLOBAL-INDEX: <li>AnotherNamespace</li>
370+
// MUSTACHE-GLOBAL-INDEX: <li>PrimaryNamespace</li>
371+
273372
// MD-GLOBAL-INDEX: # Global Namespace
274373
// MD-GLOBAL-INDEX: ## Namespaces
275374
// MD-GLOBAL-INDEX: * [@nonymous_namespace](..{{[\/]}}@nonymous_namespace{{[\/]}}index.md)

0 commit comments

Comments
 (0)