[clang-tools-extra] [clang-doc] Add md_mustache lit test coverage to existing test files (PR #203013)
Neil Nair via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 10 08:20:54 PDT 2026
https://github.com/Neil-N4 created https://github.com/llvm/llvm-project/pull/203013
Adds md_mustache RUN lines and FileCheck checks to 7 existing lit tests that had no Mustache MD coverage. Closes #201945. Files updated: typedef-alias.cpp, long-name.cpp, single-file.cpp, single-file-public.cpp, compact.cpp, conversion_function.cpp, index.cpp. Where the Mustache generator doesn't support a feature yet (typedefs, for instance), CHECK-NOT lines document the gap. Assisted-by: Claude
>From 8d526f115094b59719ef5da88983021e1344b7bc Mon Sep 17 00:00:00 2001
From: Neil-N4 <neilnair4 at gmail.com>
Date: Wed, 10 Jun 2026 10:50:27 -0400
Subject: [PATCH 1/7] [clang-doc] Add md_mustache checks to typedef-alias test
---
.../test/clang-doc/typedef-alias.cpp | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/clang-tools-extra/test/clang-doc/typedef-alias.cpp b/clang-tools-extra/test/clang-doc/typedef-alias.cpp
index c4dad4c25f2e0..28186b38b32b3 100644
--- a/clang-tools-extra/test/clang-doc/typedef-alias.cpp
+++ b/clang-tools-extra/test/clang-doc/typedef-alias.cpp
@@ -3,6 +3,9 @@
// RUN: FileCheck %s < %t/html/GlobalNamespace/index.html -check-prefix=HTML-GLOBAL
// RUN: FileCheck %s < %t/html/GlobalNamespace/index.html -check-prefix=HTML-GLOBAL
// RUN: FileCheck %s < %t/html/GlobalNamespace/_ZTV6Vector.html -check-prefix=HTML-VECTOR
+// RUN: clang-doc --format=md_mustache --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/md/GlobalNamespace/index.md -check-prefix=MD-MUSTACHE-GLOBAL
+// RUN: FileCheck %s < %t/md/GlobalNamespace/_ZTV6Vector.md -check-prefix=MD-MUSTACHE-VECTOR
/// \brief This is u_long
using u_long = unsigned long;
@@ -80,3 +83,16 @@ using IntVec = Vector<int>;
// HTML-VECTOR-NEXT: <p>Defined at line 16 of file {{.*}}typedef-alias.cpp</p>
// HTML-VECTOR-NEXT: </div>
// HTML-VECTOR-NEXT: </section>
+
+// MD-MUSTACHE-GLOBAL: # Global Namespace
+// MD-MUSTACHE-GLOBAL: ## Records
+// MD-MUSTACHE-GLOBAL: * [Vector](Vector.md)
+// MD-MUSTACHE-GLOBAL-NOT: ## Typedefs
+// MD-MUSTACHE-GLOBAL-NOT: u_long
+// MD-MUSTACHE-GLOBAL-NOT: IntPtr
+// MD-MUSTACHE-GLOBAL-NOT: IntVec
+
+// MD-MUSTACHE-VECTOR: # class Vector
+// MD-MUSTACHE-VECTOR: *Defined at {{.*}}typedef-alias.cpp#17*
+// MD-MUSTACHE-VECTOR-NOT: ## Typedefs
+// MD-MUSTACHE-VECTOR-NOT: using Ptr
\ No newline at end of file
>From ea0c7df4f7068e4991d6fd283759cbfd16e8e056 Mon Sep 17 00:00:00 2001
From: Neil-N4 <neilnair4 at gmail.com>
Date: Wed, 10 Jun 2026 10:54:58 -0400
Subject: [PATCH 2/7] [clang-doc] Add md_mustache checks to long-name test
---
clang-tools-extra/test/clang-doc/long-name.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/clang-tools-extra/test/clang-doc/long-name.cpp b/clang-tools-extra/test/clang-doc/long-name.cpp
index e4a5e29f973d5..b799af1fbb0f4 100644
--- a/clang-tools-extra/test/clang-doc/long-name.cpp
+++ b/clang-tools-extra/test/clang-doc/long-name.cpp
@@ -4,6 +4,8 @@
// RUN: clang-doc --output=%t --format=html --executor=standalone %s
// RUN: ls %t/json/GlobalNamespace | FileCheck %s -check-prefix=CHECK-JSON
// RUN: ls %t/html/GlobalNamespace | FileCheck %s -check-prefix=CHECK-HTML
+// RUN: clang-doc --format=md_mustache --output=%t --executor=standalone %s
+// RUN: ls %t/md/GlobalNamespace | FileCheck %s -check-prefix=CHECK-MD-MUSTACHE
struct ThisStructHasANameThatResultsInAMangledNameThatIsExactly250CharactersLongThatIsSupposedToTestTheFilenameLengthLimitsWithinClangDocInOrdertoSeeifclangdocwillcrashornotdependingonthelengthofthestructIfTheLengthIsTooLongThenClangDocWillCrashAnd12 {};
@@ -14,3 +16,5 @@ struct ThisStructHasANameThatResultsInAMangledNameThatIsExactly251CharactersLong
// CHECK-JSON: _ZTV244ThisStructHasANameThatResultsInAMangledNameThatIsExactly251CharactersLongThatIsSupposedToTestTheFilenameLengthLimitsWithinClangDocInOrdertoSeeifclangdocwillcrashornotdependingonthelengthofthestructIfTheL29DE8558215A13A506661C0E01E50AA3E5C9C7FA.json
// CHECK-HTML: ThisStructHasANameThatResultsInAMangledNameThatIsExactly250CharactersLongThatIsSupposedToTestTheFilenameLengthLimitsWithinClangDocInOrdertoSeeifclangdocwillcrashornotdependingonthelengthofthestructIfTheLengthIsTooLongThenClangDocWillCrashAnd12.html
// CHECK-HTML: _ZTV244ThisStructHasANameThatResultsInAMangledNameThatIsExactly251CharactersLongThatIsSupposedToTestTheFilenameLengthLimitsWithinClangDocInOrdertoSeeifclangdocwillcrashornotdependingonthelengthofthestructIfTheL29DE8558215A13A506661C0E01E50AA3E5C9C7FA.html
+// CHECK-MD-MUSTACHE: _ZTV243ThisStructHasANameThatResultsInAMangledNameThatIsExactly250CharactersLongThatIsSupposedToTestTheFilenameLengthLimitsWithinClangDocInOrdertoSeeifclangdocwillcrashornotdependingonthelengthofthestructIfTheLengthIsTooLongThenClangDocWillCrashAnd12.md
+// CHECK-MD-MUSTACHE: _ZTV244ThisStructHasANameThatResultsInAMangledNameThatIsExactly251CharactersLongThatIsSupposedToTestTheFilenameLengthLimitsWithinClangDocInOrdertoSeeifclangdocwillcrashornotdependingonthelengthofthestructIfTheL29DE8558215A13A506661C0E01E50AA3E5C9C7FA.md
\ No newline at end of file
>From 2d92255d9e8d467f410442e10808cf164e259d88 Mon Sep 17 00:00:00 2001
From: Neil-N4 <neilnair4 at gmail.com>
Date: Wed, 10 Jun 2026 10:59:29 -0400
Subject: [PATCH 3/7] [clang-doc] Add md_mustache checks to single-file test
---
clang-tools-extra/test/clang-doc/single-file.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/clang-tools-extra/test/clang-doc/single-file.cpp b/clang-tools-extra/test/clang-doc/single-file.cpp
index bea434eb2ed9a..c067a633126ed 100644
--- a/clang-tools-extra/test/clang-doc/single-file.cpp
+++ b/clang-tools-extra/test/clang-doc/single-file.cpp
@@ -3,6 +3,8 @@
// RUN: cp "%s" "%t/test.cpp"
// RUN: clang-doc --doxygen --executor=standalone -p %t %t/test.cpp -output=%t/docs
// RUN: FileCheck %s -input-file=%t/docs/index.yaml --check-prefix=CHECK
+// RUN: clang-doc --doxygen --format=md_mustache --output=%t --executor=standalone %s
+// RUN: FileCheck %s --input-file=%t/md/GlobalNamespace/index.md --check-prefix=MD-MUSTACHE
void function(int x);
@@ -29,3 +31,8 @@ void function(int x) {}
// CHECK-NEXT: Name: 'void'
// CHECK-NEXT: QualName: 'void'
// CHECK-NEXT:...
+
+// MD-MUSTACHE: # Global Namespace
+// MD-MUSTACHE: ## Functions
+// MD-MUSTACHE: ### function
+// MD-MUSTACHE: *void function(int x)*
\ No newline at end of file
>From 46538d69a7f16ec59e7faffd9796fac8682c6655 Mon Sep 17 00:00:00 2001
From: Neil-N4 <neilnair4 at gmail.com>
Date: Wed, 10 Jun 2026 11:04:11 -0400
Subject: [PATCH 4/7] [clang-doc] Add md_mustache checks to single-file-public
test
---
.../test/clang-doc/single-file-public.cpp | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/clang-tools-extra/test/clang-doc/single-file-public.cpp b/clang-tools-extra/test/clang-doc/single-file-public.cpp
index a2a76b60c02db..7c828d136c550 100644
--- a/clang-tools-extra/test/clang-doc/single-file-public.cpp
+++ b/clang-tools-extra/test/clang-doc/single-file-public.cpp
@@ -6,6 +6,9 @@
// (which we don't know in advance). This checks the record file by searching
// for a name with a 40-char USR name.
// RUN: find %t/docs -regex ".*/[0-9A-F]*.yaml" -exec cat {} ";" | FileCheck %s --check-prefix=CHECK
+// RUN: clang-doc --doxygen --public --format=md_mustache --output=%t --executor=standalone %s
+// RUN: FileCheck %s --input-file=%t/md/GlobalNamespace/index.md --check-prefix=MD-MUSTACHE-GLOBAL
+// RUN: FileCheck %s --input-file=%t/md/GlobalNamespace/_ZTV6Record.md --check-prefix=MD-MUSTACHE-RECORD
class Record {
private:
@@ -60,3 +63,13 @@ void Record::function_public() {}
// CHECK-NEXT: QualName: 'void'
// CHECK-NEXT: Access: Public
// CHECK-NEXT: ...
+
+// MD-MUSTACHE-GLOBAL: # Global Namespace
+// MD-MUSTACHE-GLOBAL: ## Records
+// MD-MUSTACHE-GLOBAL: * [Record](Record.md)
+
+// MD-MUSTACHE-RECORD: # class Record
+// MD-MUSTACHE-RECORD: ## Functions
+// MD-MUSTACHE-RECORD: ### function_public
+// MD-MUSTACHE-RECORD: *public void function_public()*
+// MD-MUSTACHE-RECORD-NOT: function_private
\ No newline at end of file
>From 4b1c831433e16fd0fa7056046a853bd02030cb9c Mon Sep 17 00:00:00 2001
From: Neil-N4 <neilnair4 at gmail.com>
Date: Wed, 10 Jun 2026 11:08:21 -0400
Subject: [PATCH 5/7] [clang-doc] Add md_mustache checks to compact test
---
clang-tools-extra/test/clang-doc/compact.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/clang-tools-extra/test/clang-doc/compact.cpp b/clang-tools-extra/test/clang-doc/compact.cpp
index e817b2a8c547b..dd3c6e54c55e8 100644
--- a/clang-tools-extra/test/clang-doc/compact.cpp
+++ b/clang-tools-extra/test/clang-doc/compact.cpp
@@ -2,6 +2,9 @@
// RUN: clang-doc --doxygen --output=%t --format=json --executor=standalone %s
// RUN: FileCheck %s < %t/json/GlobalNamespace/_ZTV3Foo.json --check-prefix=CLASS
// RUN: FileCheck %s < %t/json/index.json --check-prefix=INDEX
+// RUN: clang-doc --doxygen --format=md_mustache --output=%t --executor=standalone %s
+// RUN: FileCheck %s --input-file=%t/md/GlobalNamespace/index.md --check-prefix=MD-MUSTACHE-GLOBAL
+// RUN: FileCheck %s --input-file=%t/md/GlobalNamespace/_ZTV3Foo.md --check-prefix=MD-MUSTACHE-FOO
class Foo {};
@@ -29,3 +32,10 @@ class Foo {};
// INDEX-SAME: "QualName":"GlobalNamespace",
// INDEX-SAME: "Type":"namespace",
// INDEX-SAME: "USR":"0000000000000000000000000000000000000000"}]}
+
+// MD-MUSTACHE-GLOBAL: # Global Namespace
+// MD-MUSTACHE-GLOBAL: ## Records
+// MD-MUSTACHE-GLOBAL: * [Foo](Foo.md)
+
+// MD-MUSTACHE-FOO: # class Foo
+// MD-MUSTACHE-FOO: *Defined at {{.*}}compact.cpp#{{[0-9]+}}*
\ No newline at end of file
>From 63942b3a9af0ce044a00f7d209f8242fa0348024 Mon Sep 17 00:00:00 2001
From: Neil-N4 <neilnair4 at gmail.com>
Date: Wed, 10 Jun 2026 11:11:50 -0400
Subject: [PATCH 6/7] [clang-doc] Add md_mustache checks to conversion_function
test
---
clang-tools-extra/test/clang-doc/conversion_function.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/clang-tools-extra/test/clang-doc/conversion_function.cpp b/clang-tools-extra/test/clang-doc/conversion_function.cpp
index 24115fc39451f..7f1d7e77ca26e 100644
--- a/clang-tools-extra/test/clang-doc/conversion_function.cpp
+++ b/clang-tools-extra/test/clang-doc/conversion_function.cpp
@@ -6,6 +6,9 @@
// RUN: clang-doc --format=html --output=%t --executor=standalone %s
// RUN: FileCheck %s < %t/html/GlobalNamespace/_ZTV8MyStruct.html --check-prefix=CHECK-HTML
+// RUN: clang-doc --doxygen --format=md_mustache --output=%t --executor=standalone %s
+// RUN: FileCheck %s --input-file=%t/md/GlobalNamespace/_ZTV8MyStruct.md --check-prefix=MD-MUSTACHE
+
template <typename T>
struct MyStruct {
operator T();
@@ -17,3 +20,8 @@ struct MyStruct {
// CHECK-HTML: <div id="{{([0-9A-F]{40})}}" class="delimiter-container">
// CHECK-HTML: <pre><code class="language-cpp code-clang-doc">T operator T ()</code></pre>
// CHECK-HTML: </div>
+
+// MD-MUSTACHE: # struct MyStruct
+// MD-MUSTACHE: ## Functions
+// MD-MUSTACHE: ### operator T
+// MD-MUSTACHE: *public T operator T()*
\ No newline at end of file
>From 56bcd6d4b8d1e43767c7f12789ecf1af05a76299 Mon Sep 17 00:00:00 2001
From: Neil-N4 <neilnair4 at gmail.com>
Date: Wed, 10 Jun 2026 11:16:16 -0400
Subject: [PATCH 7/7] [clang-doc] Add md_mustache checks to index test
---
clang-tools-extra/test/clang-doc/index.cpp | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/clang-tools-extra/test/clang-doc/index.cpp b/clang-tools-extra/test/clang-doc/index.cpp
index afe34e248d3f2..82971e184716c 100644
--- a/clang-tools-extra/test/clang-doc/index.cpp
+++ b/clang-tools-extra/test/clang-doc/index.cpp
@@ -2,6 +2,9 @@
// RUN: clang-doc --format=html --pretty-json --output=%t --executor=standalone %s
// RUN: FileCheck %s < %t/json/index.json -check-prefix=CHECK-JSON
// RUN: FileCheck %s < %t/html/index.html -check-prefix=CHECK-HTML
+// RUN: clang-doc --doxygen --format=md_mustache --output=%t --executor=standalone %s
+// RUN: FileCheck %s --input-file=%t/md/index.md --check-prefix=MD-MUSTACHE-INDEX
+// RUN: FileCheck %s --input-file=%t/md/GlobalNamespace/index.md --check-prefix=MD-MUSTACHE-GLOBAL
class Foo {};
@@ -65,4 +68,12 @@ namespace inner {
// CHECK-HTML-NEXT: </div>
// CHECK-HTML-NEXT: </main>
-// COM: TODO: Add Markdown index test
+// MD-MUSTACHE-INDEX: C/C++ Reference
+// MD-MUSTACHE-INDEX: * Namespace: [GlobalNamespace](GlobalNamespace)
+// MD-MUSTACHE-INDEX: * Namespace: [inner](inner)
+
+// MD-MUSTACHE-GLOBAL: # Global Namespace
+// MD-MUSTACHE-GLOBAL: ## Namespaces
+// MD-MUSTACHE-GLOBAL: * [inner](../inner/index.md)
+// MD-MUSTACHE-GLOBAL: ## Records
+// MD-MUSTACHE-GLOBAL: * [Foo](Foo.md)
\ No newline at end of file
More information about the cfe-commits
mailing list