[clang-tools-extra] [clang-doc] Fix `</section>` mismatch in the namespace template (PR #168966)

Erick Velez via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 21 10:08:01 PST 2025


https://github.com/evelez7 updated https://github.com/llvm/llvm-project/pull/168966

>From 0cd3d591c9a6619bc75458b3c26f1109395b9954 Mon Sep 17 00:00:00 2001
From: Erick Velez <erickvelez7 at gmail.com>
Date: Thu, 20 Nov 2025 14:55:55 -0800
Subject: [PATCH] [clang-doc] Fix `</section>` mismatch in the namespace
 template

A `</section>` tag wasn't inside the `{{#HasRecords}}` Mustache tag, which caused a
mismatch if there weren't any records to render.
---
 .../clang-doc/assets/namespace-template.mustache  |  2 +-
 .../clang-doc/mustache-separate-namespace.cpp     | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/assets/namespace-template.mustache b/clang-tools-extra/clang-doc/assets/namespace-template.mustache
index f4a35cfe4c79a..614023b9f6723 100644
--- a/clang-tools-extra/clang-doc/assets/namespace-template.mustache
+++ b/clang-tools-extra/clang-doc/assets/namespace-template.mustache
@@ -97,8 +97,8 @@
                             </li>
                         {{/Records}}
                         </ul>
-                    {{/HasRecords}}
                     </section>
+                    {{/HasRecords}}
                 </div>
             </div>
         </main>
diff --git a/clang-tools-extra/test/clang-doc/mustache-separate-namespace.cpp b/clang-tools-extra/test/clang-doc/mustache-separate-namespace.cpp
index ee8b844d1f7f1..607c7087f3b59 100644
--- a/clang-tools-extra/test/clang-doc/mustache-separate-namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/mustache-separate-namespace.cpp
@@ -1,6 +1,7 @@
 // RUN: rm -rf %t && mkdir -p %t
 // RUN: clang-doc --format=mustache --output=%t --executor=standalone %s 
 // RUN: FileCheck %s < %t/html/MyNamespace/index.html
+// RUN: FileCheck %s < %t/html/GlobalNamespace/index.html --check-prefix=CHECK-GLOBAL
 
 namespace MyNamespace {
   class Foo;
@@ -13,3 +14,17 @@ namespace MyNamespace {
 // CHECK-NEXT:        </a>
 // CHECK-NEXT:    </li>
 // CHECK-NEXT: </ul>
+
+// COM: Check that the empty global namespace doesn't contain tag mismatches.
+// CHECK-GLOBAL:             <main>
+// CHECK-GLOBAL-NEXT:            <div class="container">
+// CHECK-GLOBAL-NEXT:                <div class="sidebar">
+// CHECK-GLOBAL-NEXT:                    <h2> </h2>
+// CHECK-GLOBAL-NEXT:                    <ul>
+// CHECK-GLOBAL-NEXT:                    </ul>
+// CHECK-GLOBAL-NEXT:                </div>
+// CHECK-GLOBAL-NEXT:                <div class="resizer" id="resizer"></div>
+// CHECK-GLOBAL-NEXT:                <div class="content">
+// CHECK-GLOBAL:                     </div>
+// CHECK-GLOBAL-NEXT:            </div>
+// CHECK-GLOBAL-NEXT:        </main>



More information about the cfe-commits mailing list