[llvm-branch-commits] [clang-tools-extra] [clang-doc] Serialize protected methods in class template (PR #174884)
Erick Velez via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jan 7 15:09:57 PST 2026
https://github.com/evelez7 created https://github.com/llvm/llvm-project/pull/174884
None
>From 61645e95d90193457af3eee639e607fcd91c0cd8 Mon Sep 17 00:00:00 2001
From: Erick Velez <erickvelez7 at gmail.com>
Date: Sun, 4 Jan 2026 21:33:01 -0800
Subject: [PATCH] [clang-doc] Serialize protected methods in class template
---
clang-tools-extra/clang-doc/JSONGenerator.cpp | 2 +-
.../clang-doc/assets/class-template.mustache | 34 +++++++++----------
.../test/clang-doc/json/class.cpp | 18 ++++++++++
3 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index fab54591b8faa..ad76c40d49db8 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -628,7 +628,7 @@ static void serializeInfo(const RecordInfo &I, json::Object &Obj,
if (!PubFunctionsArrayRef.empty())
insertArray(Obj, PubFunctionsArray, "PublicFunctions");
if (!ProtFunctionsArrayRef.empty())
- Obj["ProtectedFunctions"] = ProtFunctionsArray;
+ insertArray(Obj, ProtFunctionsArray, "ProtectedFunctions");
}
if (!I.Members.empty()) {
diff --git a/clang-tools-extra/clang-doc/assets/class-template.mustache b/clang-tools-extra/clang-doc/assets/class-template.mustache
index 19e6e6adf1b44..368fc0472b3ca 100644
--- a/clang-tools-extra/clang-doc/assets/class-template.mustache
+++ b/clang-tools-extra/clang-doc/assets/class-template.mustache
@@ -63,22 +63,22 @@
</details>
</li>
{{/HasPublicFunctions}}
- {{#ProtectedFunction}}
+ {{#HasProtectedFunctions}}
<li>
<details open>
<summary class="sidebar-section">
- <a class="sidebar-item" href="#ProtectedFunction">Protected Method</a>
+ <a class="sidebar-item" href="#ProtectedMethods">Protected Methods</a>
</summary>
<ul>
- {{#Obj}}
+ {{#ProtectedFunctions}}
<li class="sidebar-item-container">
- <a class="sidebar-item" href="#{{ID}}">{{Name}}</a>
+ <a class="sidebar-item" href="#{{USR}}">{{Name}}</a>
</li>
- {{/Obj}}
+ {{/ProtectedFunctions}}
</ul>
</details>
</li>
- {{/ProtectedFunction}}
+ {{/HasProtectedFunctions}}
{{#HasEnums}}
<li>
<details open>
@@ -198,18 +198,16 @@
{{/PublicFunctions}}
</section>
{{/PublicFunctions}}
- {{#ProtectedFunction}}
- <li class="sidebar-section">
- <a class="sidebar-item" href="#ProtectedFunction">Protected Method</a>
- </li>
- <ul>
- {{#Obj}}
- <li class="sidebar-item-container">
- <a class="sidebar-item" href="#{{ID}}">{{Name}}</a>
- </li>
- {{/Obj}}
- </ul>
- {{/ProtectedFunction}}
+ {{#HasProtectedFunctions}}
+ <section id="ProtectedMethods" class="section-container">
+ <h2>Protected Methods</h2>
+ <div>
+ {{#PublicFunctions}}
+ {{>FunctionPartial}}
+ {{/PublicFunctions}}
+ </div>
+ </section>
+ {{/HasProtectedFunctions}}
{{#HasEnums}}
<section id="Enums" class="section-container">
<h2>Enumerations</h2>
diff --git a/clang-tools-extra/test/clang-doc/json/class.cpp b/clang-tools-extra/test/clang-doc/json/class.cpp
index 6356aee14c16c..869c6635418ae 100644
--- a/clang-tools-extra/test/clang-doc/json/class.cpp
+++ b/clang-tools-extra/test/clang-doc/json/class.cpp
@@ -170,6 +170,7 @@ struct MyClass {
// CHECK-NEXT: "HasEnums": true,
// CHECK-NEXT: "HasFriends": true,
// CHECK-NEXT: "HasPrivateMembers": true,
+// CHECK-NEXT: "HasProtectedFunctions": true,
// CHECK-NEXT: "HasProtectedMembers": true,
// CHECK-NEXT: "HasPublicFunctions": true,
// CHECK-NEXT: "HasPublicMembers": true,
@@ -329,6 +330,23 @@ struct MyClass {
// HTML-NEXT: </div>
// HTML-NEXT: </div>
// HTML-NEXT: </section>
+// HTML: <section id="ProtectedMethods" class="section-container">
+// HTML-NEXT: <h2>Protected Methods</h2>
+// HTML-NEXT: <div>
+// HTML-NEXT: <div id="{{([0-9A-F]{40})}}" class="delimiter-container">
+// HTML-NEXT: <pre><code class="language-cpp code-clang-doc">int myMethod (int MyParam)</code></pre>
+// HTML-NEXT: <p>Defined at line of file </p>
+// HTML-NEXT: </div>
+// HTML-NEXT: <div id="{{([0-9A-F]{40})}}" class="delimiter-container">
+// HTML-NEXT: <pre><code class="language-cpp code-clang-doc">void staticMethod ()</code></pre>
+// HTML-NEXT: <p>Defined at line of file </p>
+// HTML-NEXT: </div>
+// HTML-NEXT: <div id="{{([0-9A-F]{40})}}" class="delimiter-container">
+// HTML-NEXT: <pre><code class="language-cpp code-clang-doc">const int & getConst ()</code></pre>
+// HTML-NEXT: <p>Defined at line of file </p>
+// HTML-NEXT: </div>
+// HTML-NEXT: </div>
+// HTML-NEXT: </section>
// HTML: <section id="Classes" class="section-container">
// HTML-NEXT: <h2>Inner Classes</h2>
// HTML-NEXT: <ul class="class-container">
More information about the llvm-branch-commits
mailing list