-
Notifications
You must be signed in to change notification settings - Fork 15.9k
[clang-doc] Add protected methods to class template #174884
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
|
@llvm/pr-subscribers-clang-tools-extra Author: Erick Velez (evelez7) ChangesProtected method tags already existed in the class template, but they didn't conform to the current JSON scheme. Full diff: https://github.com/llvm/llvm-project/pull/174884.diff 3 Files Affected:
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">
|
61645e9 to
9f8ecf5
Compare
| insertArray(Obj, PubFunctionsArray, "PublicFunctions"); | ||
| if (!ProtFunctionsArrayRef.empty()) | ||
| Obj["ProtectedFunctions"] = ProtFunctionsArray; | ||
| insertArray(Obj, ProtFunctionsArray, "ProtectedFunctions"); |
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.
| insertArray(Obj, ProtFunctionsArray, "ProtectedFunctions"); | |
| insertArray(Obj, ProtFunctionsArray, "ProtectedMethods"); |
If we're touching this, maybe we should name these and the tags in the templates consistently? WDYT? I'm fine either way, and this is more a minor nit than something that should block landing. We can follow up later w/ a small cleanup.
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.
Yeah these names need to be cleaned up across the templates as well, but I've put it off to not make these patches unnecessarily large and to get the functionality out there first. I'm planning to followup on these soon.
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.
sounds good. When one of us gets a chance lets clean those up. Or file a bug and tag it good first issue? its a trivial thing to do for a new person, so maybe that's better?
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.
I already have a chore patch ready with it unfortunately. I can separate it out since it has a few more things that needed to be addressed like typos.
9f8ecf5 to
2aa48a0
Compare
Protected method tags already existed in the class template, but they didn't conform to the current JSON scheme.
Protected method tags already existed in the class template, but they didn't conform to the current JSON scheme.

Protected method tags already existed in the class template, but they didn't conform to the current JSON scheme.