-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang-doc] add return comments to comment template #150647
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) Changes[clang-doc] add return comments to comment template Serialize return comments in HTML templates. Full diff: https://github.com/llvm/llvm-project/pull/150647.diff 3 Files Affected:
diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index 5fc28406ee870..cae1a686266c6 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -126,6 +126,8 @@ static Object serializeComment(const CommentInfo &I, Object &Description) {
auto TextCommentsArray = extractTextComments(CARef.front().getAsObject());
if (I.Name == "brief")
insertComment(Description, TextCommentsArray, "BriefComments");
+ else if (I.Name == "return")
+ insertComment(Description, TextCommentsArray, "ReturnComments");
return Obj;
}
diff --git a/clang-tools-extra/clang-doc/assets/comment-template.mustache b/clang-tools-extra/clang-doc/assets/comment-template.mustache
index d55a53194ee5c..89c48d26278c0 100644
--- a/clang-tools-extra/clang-doc/assets/comment-template.mustache
+++ b/clang-tools-extra/clang-doc/assets/comment-template.mustache
@@ -32,6 +32,14 @@
</div>
{{/ParamComments}}
{{/HasParamComments}}
+{{#HasReturnComments}}
+ <h3>Returns</h3>
+ {{#ReturnComments}}
+ {{#.}}
+ <p>{{TextComment}}</p>
+ {{/.}}
+ {{/ReturnComments}}
+{{/HasReturnComments}}
{{#BlockCommandComment}}
<div class="block-command-comment__command">
<div class="block-command-command">
diff --git a/clang-tools-extra/test/clang-doc/basic-project.mustache.test b/clang-tools-extra/test/clang-doc/basic-project.mustache.test
index b55e0abe2cdef..2c87fe2533195 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.mustache.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.mustache.test
@@ -93,6 +93,8 @@ HTML-SHAPE: </div>
HTML-SHAPE: <div>
HTML-SHAPE: <p></p>
HTML-SHAPE: </div>
+HTML-SHAPE: <h3>Returns</h3>
+HTML-SHAPE: <p> double The area of the shape.</p>
HTML-SHAPE: </div>
HTML-SHAPE: </div>
HTML-SHAPE: </div>
@@ -113,6 +115,8 @@ HTML-SHAPE: </div>
HTML-SHAPE: <div>
HTML-SHAPE: <p></p>
HTML-SHAPE: </div>
+HTML-SHAPE: <h3>Returns</h3>
+HTML-SHAPE: <p> double The perimeter of the shape.</p>
HTML-SHAPE: </div>
HTML-SHAPE: </div>
HTML-SHAPE: </div>
@@ -277,6 +281,8 @@ HTML-CALC: <div>
HTML-CALC: <p></p>
HTML-CALC: </div>
HTML-CALC: </div>
+HTML-CALC: <h3>Returns</h3>
+HTML-CALC: <p> int The sum of a and b.</p>
HTML-CALC: </div>
HTML-CALC: </div>
HTML-CALC: </div>
@@ -297,6 +303,8 @@ HTML-CALC: </div>
HTML-CALC: <div>
HTML-CALC: <p></p>
HTML-CALC: </div>
+HTML-CALC: <h3>Returns</h3>
+HTML-CALC: <p> int The result of a - b.</p>
HTML-CALC: </div>
HTML-CALC: </div>
HTML-CALC: </div>
@@ -334,6 +342,8 @@ HTML-CALC: <div>
HTML-CALC: <p></p>
HTML-CALC: </div>
HTML-CALC: </div>
+HTML-CALC: <h3>Returns</h3>
+HTML-CALC: <p> int The product of a and b.</p>
HTML-CALC: </div>
HTML-CALC: </div>
HTML-CALC: </div>
@@ -371,6 +381,9 @@ HTML-CALC: <div>
HTML-CALC: <p></p>
HTML-CALC: </div>
HTML-CALC: </div>
+HTML-CALC: <h3>Returns</h3>
+HTML-CALC: <p> double The result of a / b.</p>
+HTML-CALC: <p></p>
HTML-CALC: </div>
HTML-CALC: </div>
HTML-CALC: </div>
@@ -408,6 +421,8 @@ HTML-CALC: <div>
HTML-CALC: <p></p>
HTML-CALC: </div>
HTML-CALC: </div>
+HTML-CALC: <h3>Returns</h3>
+HTML-CALC: <p> The result of a % b.</p>
HTML-CALC: </div>
HTML-CALC: </div>
HTML-CALC: </div>
@@ -541,6 +556,8 @@ HTML-RECTANGLE: </div>
HTML-RECTANGLE: <div>
HTML-RECTANGLE: <p></p>
HTML-RECTANGLE: </div>
+HTML-RECTANGLE: <h3>Returns</h3>
+HTML-RECTANGLE: <p> double The area of the rectangle.</p>
HTML-RECTANGLE: </div>
HTML-RECTANGLE: </div>
HTML-RECTANGLE: </div>
@@ -561,6 +578,8 @@ HTML-RECTANGLE: </div>
HTML-RECTANGLE: <div>
HTML-RECTANGLE: <p></p>
HTML-RECTANGLE: </div>
+HTML-RECTANGLE: <h3>Returns</h3>
+HTML-RECTANGLE: <p> double The perimeter of the rectangle.</p>
HTML-RECTANGLE: </div>
HTML-RECTANGLE: </div>
HTML-RECTANGLE: </div>
@@ -686,6 +705,8 @@ HTML-CIRCLE: </div>
HTML-CIRCLE: <div>
HTML-CIRCLE: <p></p>
HTML-CIRCLE: </div>
+HTML-CIRCLE: <h3>Returns</h3>
+HTML-CIRCLE: <p> double The area of the circle.</p>
HTML-CIRCLE: </div>
HTML-CIRCLE: </div>
HTML-CIRCLE: </div>
@@ -706,6 +727,8 @@ HTML-CIRCLE: </div>
HTML-CIRCLE: <div>
HTML-CIRCLE: <p></p>
HTML-CIRCLE: </div>
+HTML-CIRCLE: <h3>Returns</h3>
+HTML-CIRCLE: <p> double The perimeter of the circle.</p>
HTML-CIRCLE: </div>
HTML-CIRCLE: </div>
HTML-CIRCLE: </div>
|
c6fbf4d
to
158802a
Compare
f46ee3e
to
6f19128
Compare
cef7188
to
17db501
Compare
68c10c8
to
518c754
Compare
Merge activity
|
2905e87
to
1090ebb
Compare
Serialize return comments in HTML templates.
1090ebb
to
7c486a6
Compare
The CI was green before I started a stack merge via Graphite. Now it's stuck in this terrible loop so I'm going to bypass the rule and force it to merge. @boomanaiden154 Not sure if you know anything about this but maybe you can point me to someone who does. I think the newly required CI rules don't play nice with Graphite auto-merging. Graphites constantly rebases the branch when trying to merge, which will cause CI to trigger again. |
I don't use Graphite and am definitely not familiar with the internal details of how it works. This seems like it's a Graphite problem more so than anything else though. Seems like someone should do some preliminary investigation and then contact the Graphite folks. |
@evelez7 Do you have more details on what exactly you did within Graphite? Did you try to merge multiple PRs in a stack or just the bottom one? |
I started a stack merge of 3 PRs starting with #150570 and this was supposed to be the 2nd one. The third PR is currently waiting for CI. I just submitted a bug report/feedback via Graphite. This seems like a pretty big problem for Graphite in LLVM so I was even wondering if merging stacks should be disabled if possible. |
I ran into a similar problem, and Nikita had to cancel the whole thing (IIRC by closing the PR and then reopening). It was not great, so I normally just merge them one at a time now. |
Serialize return comments in HTML templates.
Serialize return comments in HTML templates.