Skip to content

Commit 68c10c8

Browse files
committed
[clang-doc] add return comments to comment template
Serialize return comments in HTML templates.
1 parent cb68a05 commit 68c10c8

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
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 & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ HTML-SHAPE: </div>
9393
HTML-SHAPE: <div>
9494
HTML-SHAPE: <p></p>
9595
HTML-SHAPE: </div>
96-
HTML-SHAPE-NOT: <h3>Returns</h3>
97-
HTML-SHAPE-NOT: <p> double The area of the shape.</p>
96+
HTML-SHAPE: <h3>Returns</h3>
97+
HTML-SHAPE: <p> double The area of the shape.</p>
9898
HTML-SHAPE: </div>
9999
HTML-SHAPE: </div>
100100
HTML-SHAPE: </div>
@@ -115,8 +115,8 @@ HTML-SHAPE: </div>
115115
HTML-SHAPE: <div>
116116
HTML-SHAPE: <p></p>
117117
HTML-SHAPE: </div>
118-
HTML-SHAPE-NOT: <h3>Returns</h3>
119-
HTML-SHAPE-NOT: <p> double The perimeter of the shape.</p>
118+
HTML-SHAPE: <h3>Returns</h3>
119+
HTML-SHAPE: <p> double The perimeter of the shape.</p>
120120
HTML-SHAPE: </div>
121121
HTML-SHAPE: </div>
122122
HTML-SHAPE: </div>
@@ -281,8 +281,8 @@ HTML-CALC: <div>
281281
HTML-CALC: <p></p>
282282
HTML-CALC: </div>
283283
HTML-CALC: </div>
284-
HTML-CALC-NOT: <h3>Returns</h3>
285-
HTML-CALC-NOT: <p> int The sum of a and b.</p>
284+
HTML-CALC: <h3>Returns</h3>
285+
HTML-CALC: <p> int The sum of a and b.</p>
286286
HTML-CALC: </div>
287287
HTML-CALC: </div>
288288
HTML-CALC: </div>
@@ -303,8 +303,8 @@ HTML-CALC: </div>
303303
HTML-CALC: <div>
304304
HTML-CALC: <p></p>
305305
HTML-CALC: </div>
306-
HTML-CALC-NOT: <h3>Returns</h3>
307-
HTML-CALC-NOT: <p> int The result of a - b.</p>
306+
HTML-CALC: <h3>Returns</h3>
307+
HTML-CALC: <p> int The result of a - b.</p>
308308
HTML-CALC: </div>
309309
HTML-CALC: </div>
310310
HTML-CALC: </div>
@@ -342,8 +342,8 @@ HTML-CALC: <div>
342342
HTML-CALC: <p></p>
343343
HTML-CALC: </div>
344344
HTML-CALC: </div>
345-
HTML-CALC-NOT: <h3>Returns</h3>
346-
HTML-CALC-NOT: <p> int The product of a and b.</p>
345+
HTML-CALC: <h3>Returns</h3>
346+
HTML-CALC: <p> int The product of a and b.</p>
347347
HTML-CALC: </div>
348348
HTML-CALC: </div>
349349
HTML-CALC: </div>
@@ -381,9 +381,9 @@ HTML-CALC: <div>
381381
HTML-CALC: <p></p>
382382
HTML-CALC: </div>
383383
HTML-CALC: </div>
384-
HTML-CALC-NOT: <h3>Returns</h3>
385-
HTML-CALC-NOT: <p> double The result of a / b.</p>
386-
HTML-CALC-NOT: <p></p>
384+
HTML-CALC: <h3>Returns</h3>
385+
HTML-CALC: <p> double The result of a / b.</p>
386+
HTML-CALC: <p></p>
387387
HTML-CALC: </div>
388388
HTML-CALC: </div>
389389
HTML-CALC: </div>
@@ -421,8 +421,8 @@ HTML-CALC: <div>
421421
HTML-CALC: <p></p>
422422
HTML-CALC: </div>
423423
HTML-CALC: </div>
424-
HTML-CALC-NOT: <h3>Returns</h3>
425-
HTML-CALC-NOT: <p> The result of a % b.</p>
424+
HTML-CALC: <h3>Returns</h3>
425+
HTML-CALC: <p> The result of a % b.</p>
426426
HTML-CALC: </div>
427427
HTML-CALC: </div>
428428
HTML-CALC: </div>
@@ -556,8 +556,8 @@ HTML-RECTANGLE: </div>
556556
HTML-RECTANGLE: <div>
557557
HTML-RECTANGLE: <p></p>
558558
HTML-RECTANGLE: </div>
559-
HTML-RECTANGLE-NOT: <h3>Returns</h3>
560-
HTML-RECTANGLE-NOT: <p> double The area of the rectangle.</p>
559+
HTML-RECTANGLE: <h3>Returns</h3>
560+
HTML-RECTANGLE: <p> double The area of the rectangle.</p>
561561
HTML-RECTANGLE: </div>
562562
HTML-RECTANGLE: </div>
563563
HTML-RECTANGLE: </div>
@@ -578,8 +578,8 @@ HTML-RECTANGLE: </div>
578578
HTML-RECTANGLE: <div>
579579
HTML-RECTANGLE: <p></p>
580580
HTML-RECTANGLE: </div>
581-
HTML-RECTANGLE-NOT: <h3>Returns</h3>
582-
HTML-RECTANGLE-NOT: <p> double The perimeter of the rectangle.</p>
581+
HTML-RECTANGLE: <h3>Returns</h3>
582+
HTML-RECTANGLE: <p> double The perimeter of the rectangle.</p>
583583
HTML-RECTANGLE: </div>
584584
HTML-RECTANGLE: </div>
585585
HTML-RECTANGLE: </div>
@@ -705,8 +705,8 @@ HTML-CIRCLE: </div>
705705
HTML-CIRCLE: <div>
706706
HTML-CIRCLE: <p></p>
707707
HTML-CIRCLE: </div>
708-
HTML-CIRCLE-NOT: <h3>Returns</h3>
709-
HTML-CIRCLE-NOT: <p> double The area of the circle.</p>
708+
HTML-CIRCLE: <h3>Returns</h3>
709+
HTML-CIRCLE: <p> double The area of the circle.</p>
710710
HTML-CIRCLE: </div>
711711
HTML-CIRCLE: </div>
712712
HTML-CIRCLE: </div>
@@ -727,8 +727,8 @@ HTML-CIRCLE: </div>
727727
HTML-CIRCLE: <div>
728728
HTML-CIRCLE: <p></p>
729729
HTML-CIRCLE: </div>
730-
HTML-CIRCLE-NOT: <h3>Returns</h3>
731-
HTML-CIRCLE-NOT: <p> double The perimeter of the circle.</p>
730+
HTML-CIRCLE: <h3>Returns</h3>
731+
HTML-CIRCLE: <p> double The perimeter of the circle.</p>
732732
HTML-CIRCLE: </div>
733733
HTML-CIRCLE: </div>
734734
HTML-CIRCLE: </div>

0 commit comments

Comments
 (0)