-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang-doc] Add Mustache HTML output to namespace test #169107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
@llvm/pr-subscribers-clang-tools-extra Author: Erick Velez (evelez7) ChangesThis patch adds Mustache HTML tests alongside the legacy HTML backend The same thing will be done for all other tests where the legacy HTML Full diff: https://github.com/llvm/llvm-project/pull/169107.diff 1 Files Affected:
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp b/clang-tools-extra/test/clang-doc/namespace.cpp
index 4fa11c78d37c0..96ea5bc52b0be 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -1,6 +1,7 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: clang-doc --format=html --output=%t --executor=standalone %s
// RUN: clang-doc --format=md --output=%t --executor=standalone %s
+// RUN: clang-doc --format=mustache --output=%t --executor=standalone %s
// RUN: FileCheck %s < %t/index_json.js -check-prefix=JSON-INDEX
// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.html -check-prefix=HTML-ANON-CLASS-LINE
// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.html -check-prefix=HTML-ANON-CLASS
@@ -38,19 +39,42 @@
// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-GLOBAL-INDEX
// RUN: FileCheck %s < %t/all_files.md -check-prefix=MD-ALL-FILES
// RUN: FileCheck %s < %t/index.md -check-prefix=MD-INDEX
+// RUN: FileCheck %s < %t/html/@nonymous_namespace/_ZTVN12_GLOBAL__N_19AnonClassE.html -check-prefix=MUSTACHE-ANON-CLASS-LINE
+// RUN: FileCheck %s < %t/html/@nonymous_namespace/_ZTVN12_GLOBAL__N_19AnonClassE.html -check-prefix=MUSTACHE-ANON-CLASS
+// RUN: FileCheck %s < %t/html/@nonymous_namespace/index.html -check-prefix=MUSTACHE-ANON-INDEX-LINE
+// RUN: FileCheck %s < %t/html/@nonymous_namespace/index.html -check-prefix=MUSTACHE-ANON-INDEX
+// RUN: FileCheck %s < %t/html/AnotherNamespace/_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.html -check-prefix=MUSTACHE-ANOTHER-CLASS-LINE
+// RUN: FileCheck %s < %t/html/AnotherNamespace/_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.html -check-prefix=MUSTACHE-ANOTHER-CLASS
+// RUN: FileCheck %s < %t/html/AnotherNamespace/index.html -check-prefix=MUSTACHE-ANOTHER-INDEX-LINE
+// RUN: FileCheck %s < %t/html/AnotherNamespace/index.html -check-prefix=MUSTACHE-ANOTHER-INDEX
+// RUN: FileCheck %s < %t/html/PrimaryNamespace/NestedNamespace/_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.html -check-prefix=MUSTACHE-NESTED-CLASS-LINE
+// RUN: FileCheck %s < %t/html/PrimaryNamespace/NestedNamespace/_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.html -check-prefix=MUSTACHE-NESTED-CLASS
+// RUN: FileCheck %s < %t/html/PrimaryNamespace/NestedNamespace/index.html -check-prefix=MUSTACHE-NESTED-INDEX-LINE
+// RUN: FileCheck %s < %t/html/PrimaryNamespace/NestedNamespace/index.html -check-prefix=MUSTACHE-NESTED-INDEX
+// RUN: FileCheck %s < %t/html/PrimaryNamespace/index.html -check-prefix=MUSTACHE-PRIMARY-INDEX-LINE
+// RUN: FileCheck %s < %t/html/PrimaryNamespace/index.html -check-prefix=MUSTACHE-PRIMARY-INDEX
+// RUN: FileCheck %s < %t/html/PrimaryNamespace/_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.html -check-prefix=MUSTACHE-PRIMARY-CLASS-LINE
+// RUN: FileCheck %s < %t/html/PrimaryNamespace/_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.html -check-prefix=MUSTACHE-PRIMARY-CLASS
+
+// COM: FIXME: Add global functions to the namespace template
+// COM: FIXME: Add namespaces to the namespace template
+// COM: FIXME: Add class definition location to class template
// Anonymous Namespace
namespace {
void anonFunction() {}
// MD-ANON-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
// HTML-ANON-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
+// MUSTACHE-ANON-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
class AnonClass {};
// MD-ANON-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
// HTML-ANON-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
+// MUSTACHE-ANON-CLASS-LINE-NOT: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// MD-ANON-CLASS: # class AnonClass
// HTML-ANON-CLASS: <h1>class AnonClass</h1>
+// MUSTACHE-ANON-CLASS: <h1 class="hero__title-large">class AnonClass</h1>
} // namespace
// MD-ANON-INDEX: # namespace @nonymous_namespace
@@ -69,17 +93,31 @@ class AnonClass {};
// HTML-ANON-INDEX: <h3 id="{{([0-9A-F]{40})}}">anonFunction</h3>
// HTML-ANON-INDEX: <p>void anonFunction()</p>
+// MUSTACHE-ANON-INDEX: <h2> @nonymous_namespace</h2>
+// MUSTACHE-ANON-INDEX: <h2>Inner Classes</h2>
+// MUSTACHE-ANON-INDEX: <ul class="class-container">
+// MUSTACHE-ANON-INDEX: <li id="7CDAAD437F3899C38719F9F23660F4D8B0217B6C" style="max-height: 40px;">
+// MUSTACHE-ANON-INDEX: <a href="_ZTVN12_GLOBAL__N_19AnonClassE.html">
+// MUSTACHE-ANON-INDEX: <pre><code class="language-cpp code-clang-doc">class AnonClass</code></pre>
+// MUSTACHE-ANON-INDEX: </a>
+// MUSTACHE-ANON-INDEX: </li>
+// MUSTACHE-ANON-INDEX-NOT: <h2 id="Functions">Functions</h2>
+// MUSTACHE-ANON-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">anonFunction</h3>
+// MUSTACHE-ANON-INDEX-NOT: <p>void anonFunction()</p>
+
// Primary Namespace
namespace PrimaryNamespace {
// Function in PrimaryNamespace
void functionInPrimaryNamespace() {}
// MD-PRIMARY-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
// HTML-PRIMARY-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
+// MUSTACHE-PRIMARY-INDEX-LINE-NOT: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// Class in PrimaryNamespace
class ClassInPrimaryNamespace {};
// MD-PRIMARY-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
// HTML-PRIMARY-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
+// MUSTACHE-PRIMARY-CLASS-LINE-NOT: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// MD-PRIMARY-CLASS: # class ClassInPrimaryNamespace
// MD-PRIMARY-CLASS: Class in PrimaryNamespace
@@ -87,23 +125,29 @@ class ClassInPrimaryNamespace {};
// HTML-PRIMARY-CLASS: <h1>class ClassInPrimaryNamespace</h1>
// HTML-PRIMARY-CLASS: <p> Class in PrimaryNamespace</p>
+// MUSTACHE-PRIMARY-CLASS: <h1 class="hero__title-large">class ClassInPrimaryNamespace</h1>
+
// Nested namespace
namespace NestedNamespace {
// Function in NestedNamespace
void functionInNestedNamespace() {}
// MD-NESTED-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
// HTML-NESTED-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
+// MUSTACHE-NESTED-INDEX-LINE-NOT: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// Class in NestedNamespace
class ClassInNestedNamespace {};
// MD-NESTED-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
// HTML-NESTED-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
+// MUSTACHE-NESTED-CLASS-LINE-NOT: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// MD-NESTED-CLASS: # class ClassInNestedNamespace
// MD-NESTED-CLASS: Class in NestedNamespace
// HTML-NESTED-CLASS: <h1>class ClassInNestedNamespace</h1>
// HTML-NESTED-CLASS: <p> Class in NestedNamespace</p>
+
+// MUSTACHE-NESTED-CLASS: <h1 class="hero__title-large">class ClassInNestedNamespace</h1>
} // namespace NestedNamespace
// MD-NESTED-INDEX: # namespace NestedNamespace
@@ -123,6 +167,20 @@ class ClassInNestedNamespace {};
// HTML-NESTED-INDEX: <h3 id="{{([0-9A-F]{40})}}">functionInNestedNamespace</h3>
// HTML-NESTED-INDEX: <p>void functionInNestedNamespace()</p>
// HTML-NESTED-INDEX: <p> Function in NestedNamespace</p>
+
+// MUSTACHE-NESTED-INDEX: <h2> NestedNamespace</h2>
+// MUSTACHE-NESTED-INDEX: <h2>Inner Classes</h2>
+// MUSTACHE-NESTED-INDEX: <ul class="class-container">
+// MUSTACHE-NESTED-INDEX: <li id="A6F2EC99DD9697793609C8B923607E79291F27FB" style="max-height: 40px;">
+// MUSTACHE-NESTED-INDEX: <a href="_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.html">
+// MUSTACHE-NESTED-INDEX: <pre><code class="language-cpp code-clang-doc">class ClassInNestedNamespace</code></pre>
+// MUSTACHE-NESTED-INDEX: </a>
+// MUSTACHE-NESTED-INDEX: </li>
+// MUSTACHE-NESTED-INDEX: </ul>
+// MUSTACHE-NESTED-INDEX-NOT: <h2 id="Functions">Functions</h2>
+// MUSTACHE-NESTED-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">functionInNestedNamespace</h3>
+// MUSTACHE-NESTED-INDEX-NOT: <p>void functionInNestedNamespace()</p>
+// MUSTACHE-NESTED-INDEX-NOT: <p> Function in NestedNamespace</p>
} // namespace PrimaryNamespace
// MD-PRIMARY-INDEX: # namespace PrimaryNamespace
@@ -147,17 +205,35 @@ class ClassInNestedNamespace {};
// HTML-PRIMARY-INDEX: <p>void functionInPrimaryNamespace()</p>
// HTML-PRIMARY-INDEX: <p> Function in PrimaryNamespace</p>
+// MUSTACHE-PRIMARY-INDEX: <h2> PrimaryNamespace</h2>
+// MUSTACHE-PRIMARY-INDEX-NOT: <h2 id="Namespaces">Namespaces</h2>
+// MUSTACHE-PRIMARY-INDEX-NOT: <a href="NestedNamespace{{[\/]}}index.html">NestedNamespace</a>
+// MUSTACHE-PRIMARY-INDEX <h2>Inner Classes</h2>
+// MUSTACHE-PRIMARY-INDEX <ul class="class-container">
+// MUSTACHE-PRIMARY-INDEX <li id="8418952B37DC934CFB4FA9B065607A53DC751F56" style="max-height: 40px;">
+// MUSTACHE-PRIMARY-INDEX <a href="_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.html">
+// MUSTACHE-PRIMARY-INDEX <pre><code class="language-cpp code-clang-doc">class ClassInPrimaryNamespace</code></pre>
+// MUSTACHE-PRIMARY-INDEX </a>
+// MUSTACHE-PRIMARY-INDEX </li>
+// MUSTACHE-PRIMARY-INDEX </ul>
+// MUSTACHE-PRIMARY-INDEX-NOT: <h2 id="Functions">Functions</h2>
+// MUSTACHE-PRIMARY-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">functionInPrimaryNamespace</h3>
+// MUSTACHE-PRIMARY-INDEX-NOT: <p>void functionInPrimaryNamespace()</p>
+// MUSTACHE-PRIMARY-INDEX-NOT: <p> Function in PrimaryNamespace</p>
+
// AnotherNamespace
namespace AnotherNamespace {
// Function in AnotherNamespace
void functionInAnotherNamespace() {}
// MD-ANOTHER-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
// HTML-ANOTHER-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
+// MUSTACHE-ANOTHER-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// Class in AnotherNamespace
class ClassInAnotherNamespace {};
// MD-ANOTHER-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
// HTML-ANOTHER-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
+// MUSTACHE-ANOTHER-CLASS-LINE-NOT: <p>Defined at line [[@LINE-3]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// MD-ANOTHER-CLASS: # class ClassInAnotherNamespace
// MD-ANOTHER-CLASS: Class in AnotherNamespace
@@ -165,6 +241,8 @@ class ClassInAnotherNamespace {};
// HTML-ANOTHER-CLASS: <h1>class ClassInAnotherNamespace</h1>
// HTML-ANOTHER-CLASS: <p> Class in AnotherNamespace</p>
+// MUSTACHE-ANOTHER-CLASS: <h1 class="hero__title-large">class ClassInAnotherNamespace</h1>
+
} // namespace AnotherNamespace
// MD-ANOTHER-INDEX: # namespace AnotherNamespace
@@ -185,6 +263,20 @@ class ClassInAnotherNamespace {};
// HTML-ANOTHER-INDEX: <p>void functionInAnotherNamespace()</p>
// HTML-ANOTHER-INDEX: <p> Function in AnotherNamespace</p>
+// MUSTACHE-ANOTHER-INDEX: <h2> AnotherNamespace</h2>
+// MUSTACHE-ANOTHER-INDEX: <h2>Inner Classes</h2>
+// MUSTACHE-ANOTHER-INDEX: <ul class="class-container">
+// MUSTACHE-ANOTHER-INDEX: <li id="A0B9DF11203D84AA749FFDBD229B430038FDB8E0" style="max-height: 40px;">
+// MUSTACHE-ANOTHER-INDEX: <a href="_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.html">
+// MUSTACHE-ANOTHER-INDEX: <pre><code class="language-cpp code-clang-doc">class ClassInAnotherNamespace</code></pre>
+// MUSTACHE-ANOTHER-INDEX: </a>
+// MUSTACHE-ANOTHER-INDEX: </li>
+// MUSTACHE-ANOTHER-INDEX: </ul>
+// MUSTACHE-ANOTHER-INDEX-NOT: <h2 id="Functions">Functions</h2>
+// MUSTACHE-ANOTHER-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">functionInAnotherNamespace</h3>
+// MUSTACHE-ANOTHER-INDEX-NOT: <p>void functionInAnotherNamespace()</p>
+// MUSTACHE-ANOTHER-INDEX-NOT: <p> Function in AnotherNamespace</p>
+
// JSON-INDEX: async function LoadIndex() {
// JSON-INDEX-NEXT: return{
// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}",
@@ -270,6 +362,13 @@ class ClassInAnotherNamespace {};
// HTML-GLOBAL-INDEX: <li>AnotherNamespace</li>
// HTML-GLOBAL-INDEX: <li>PrimaryNamespace</li>
+// MUSTACHE-GLOBAL-INDEX: <div id="main-content" class="col-xs-12 col-sm-9 col-md-8 main-content">
+// MUSTACHE-GLOBAL-INDEX: <h1>Global Namespace</h1>
+// MUSTACHE-GLOBAL-INDEX: <h2 id="Namespaces">Namespaces</h2>
+// MUSTACHE-GLOBAL-INDEX: <li>@nonymous_namespace</li>
+// MUSTACHE-GLOBAL-INDEX: <li>AnotherNamespace</li>
+// MUSTACHE-GLOBAL-INDEX: <li>PrimaryNamespace</li>
+
// MD-GLOBAL-INDEX: # Global Namespace
// MD-GLOBAL-INDEX: ## Namespaces
// MD-GLOBAL-INDEX: * [@nonymous_namespace](..{{[\/]}}@nonymous_namespace{{[\/]}}index.md)
|
🐧 Linux x64 Test Results
|
ilovepi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, modulo a minor test fixup.
|
Actually, thinking about this for another second. If our plan is to remove the old backend, do we care about test parity? Is it valuable? We already think the old output is bad, and have basically stopped adding new features to it. Do you think its a more valuable use of time to just audit these, and swap out the current tests for mustache when we delete the other backend? a quick way to check would just to change the enum behavior when we select html to do the mustache thing instead. The diffs on all tests would probably give a clearer picture of what's changing. |
What I do find useful is having a verifiable source saying this is what the new backend emits compared to the old one. These tests are the only verification of what is actually implemented in the backend which is a pretty big problem because the actual output can have way more stuff. I learned that while implementing a Mustache MD backend - the old MD backend has way more functionality and output than what's tested. In this case, the precommit shows that we don't have certain important things in the templates, but you're right that the history might not look as good once the I'm already not copying the output 1:1 now anyways. You can see that for example on line 128 where I omitted the |
|
I'm not concerned at all about the history. Just wondering how much value it brings to the table to do this incrementally. I'm mostly fine with this, or with us switching mustache to be the default, and making the old implementation the |
|
I think once I'm done adding these tests we can switch pretty comfortably. I'd just like to switch without regressing on the output, or at least documenting what's there and what's not since that's been a problem with clang-doc. |
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.
79f518f to
7ad494f
Compare
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.

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.