Skip to content

Commit d32da62

Browse files
evelez7mahesh-attarde
authored andcommitted
[clang-doc] add return comments to comment template (llvm#150647)
Serialize return comments in HTML templates.
1 parent 5a1c776 commit d32da62

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

clang-tools-extra/clang-doc/JSONGenerator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ static Object serializeComment(const CommentInfo &I, Object &Description) {
126126
auto TextCommentsArray = extractTextComments(CARef.front().getAsObject());
127127
if (I.Name == "brief")
128128
insertComment(Description, TextCommentsArray, "BriefComments");
129+
else if (I.Name == "return")
130+
insertComment(Description, TextCommentsArray, "ReturnComments");
129131
return Obj;
130132
}
131133

clang-tools-extra/clang-doc/assets/comment-template.mustache

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
</div>
3333
{{/ParamComments}}
3434
{{/HasParamComments}}
35+
{{#HasReturnComments}}
36+
<h3>Returns</h3>
37+
{{#ReturnComments}}
38+
{{#.}}
39+
<p>{{TextComment}}</p>
40+
{{/.}}
41+
{{/ReturnComments}}
42+
{{/HasReturnComments}}
3543
{{#BlockCommandComment}}
3644
<div class="block-command-comment__command">
3745
<div class="block-command-command">

clang-tools-extra/test/clang-doc/basic-project.mustache.test

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ HTML-SHAPE: </div>
9393
HTML-SHAPE: <div>
9494
HTML-SHAPE: <p></p>
9595
HTML-SHAPE: </div>
96+
HTML-SHAPE: <h3>Returns</h3>
97+
HTML-SHAPE: <p> double The area of the shape.</p>
9698
HTML-SHAPE: </div>
9799
HTML-SHAPE: </div>
98100
HTML-SHAPE: </div>
@@ -113,6 +115,8 @@ HTML-SHAPE: </div>
113115
HTML-SHAPE: <div>
114116
HTML-SHAPE: <p></p>
115117
HTML-SHAPE: </div>
118+
HTML-SHAPE: <h3>Returns</h3>
119+
HTML-SHAPE: <p> double The perimeter of the shape.</p>
116120
HTML-SHAPE: </div>
117121
HTML-SHAPE: </div>
118122
HTML-SHAPE: </div>
@@ -277,6 +281,8 @@ HTML-CALC: <div>
277281
HTML-CALC: <p></p>
278282
HTML-CALC: </div>
279283
HTML-CALC: </div>
284+
HTML-CALC: <h3>Returns</h3>
285+
HTML-CALC: <p> int The sum of a and b.</p>
280286
HTML-CALC: </div>
281287
HTML-CALC: </div>
282288
HTML-CALC: </div>
@@ -297,6 +303,8 @@ HTML-CALC: </div>
297303
HTML-CALC: <div>
298304
HTML-CALC: <p></p>
299305
HTML-CALC: </div>
306+
HTML-CALC: <h3>Returns</h3>
307+
HTML-CALC: <p> int The result of a - b.</p>
300308
HTML-CALC: </div>
301309
HTML-CALC: </div>
302310
HTML-CALC: </div>
@@ -334,6 +342,8 @@ HTML-CALC: <div>
334342
HTML-CALC: <p></p>
335343
HTML-CALC: </div>
336344
HTML-CALC: </div>
345+
HTML-CALC: <h3>Returns</h3>
346+
HTML-CALC: <p> int The product of a and b.</p>
337347
HTML-CALC: </div>
338348
HTML-CALC: </div>
339349
HTML-CALC: </div>
@@ -371,6 +381,9 @@ HTML-CALC: <div>
371381
HTML-CALC: <p></p>
372382
HTML-CALC: </div>
373383
HTML-CALC: </div>
384+
HTML-CALC: <h3>Returns</h3>
385+
HTML-CALC: <p> double The result of a / b.</p>
386+
HTML-CALC: <p></p>
374387
HTML-CALC: </div>
375388
HTML-CALC: </div>
376389
HTML-CALC: </div>
@@ -408,6 +421,8 @@ HTML-CALC: <div>
408421
HTML-CALC: <p></p>
409422
HTML-CALC: </div>
410423
HTML-CALC: </div>
424+
HTML-CALC: <h3>Returns</h3>
425+
HTML-CALC: <p> The result of a % b.</p>
411426
HTML-CALC: </div>
412427
HTML-CALC: </div>
413428
HTML-CALC: </div>
@@ -541,6 +556,8 @@ HTML-RECTANGLE: </div>
541556
HTML-RECTANGLE: <div>
542557
HTML-RECTANGLE: <p></p>
543558
HTML-RECTANGLE: </div>
559+
HTML-RECTANGLE: <h3>Returns</h3>
560+
HTML-RECTANGLE: <p> double The area of the rectangle.</p>
544561
HTML-RECTANGLE: </div>
545562
HTML-RECTANGLE: </div>
546563
HTML-RECTANGLE: </div>
@@ -561,6 +578,8 @@ HTML-RECTANGLE: </div>
561578
HTML-RECTANGLE: <div>
562579
HTML-RECTANGLE: <p></p>
563580
HTML-RECTANGLE: </div>
581+
HTML-RECTANGLE: <h3>Returns</h3>
582+
HTML-RECTANGLE: <p> double The perimeter of the rectangle.</p>
564583
HTML-RECTANGLE: </div>
565584
HTML-RECTANGLE: </div>
566585
HTML-RECTANGLE: </div>
@@ -686,6 +705,8 @@ HTML-CIRCLE: </div>
686705
HTML-CIRCLE: <div>
687706
HTML-CIRCLE: <p></p>
688707
HTML-CIRCLE: </div>
708+
HTML-CIRCLE: <h3>Returns</h3>
709+
HTML-CIRCLE: <p> double The area of the circle.</p>
689710
HTML-CIRCLE: </div>
690711
HTML-CIRCLE: </div>
691712
HTML-CIRCLE: </div>
@@ -706,6 +727,8 @@ HTML-CIRCLE: </div>
706727
HTML-CIRCLE: <div>
707728
HTML-CIRCLE: <p></p>
708729
HTML-CIRCLE: </div>
730+
HTML-CIRCLE: <h3>Returns</h3>
731+
HTML-CIRCLE: <p> double The perimeter of the circle.</p>
709732
HTML-CIRCLE: </div>
710733
HTML-CIRCLE: </div>
711734
HTML-CIRCLE: </div>

0 commit comments

Comments
 (0)