Author: Erick Velez Date: 2025-07-25T11:16:04-07:00 New Revision: 80594820512605f25993b28d0aab2214d5308d59
URL: https://github.com/llvm/llvm-project/commit/80594820512605f25993b28d0aab2214d5308d59 DIFF: https://github.com/llvm/llvm-project/commit/80594820512605f25993b28d0aab2214d5308d59.diff LOG: [clang-doc] add param comments to comment template (#150571) Serializes parameter comments for all descriptions. We do not support Doxygen's parameter checking, which warns if a documented parameter is not actually present. Added: Modified: clang-tools-extra/clang-doc/JSONGenerator.cpp clang-tools-extra/clang-doc/assets/comment-template.mustache clang-tools-extra/test/clang-doc/basic-project.mustache.test Removed: ################################################################################ diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp b/clang-tools-extra/clang-doc/JSONGenerator.cpp index 92a4117c4e534..5fc28406ee870 100644 --- a/clang-tools-extra/clang-doc/JSONGenerator.cpp +++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp @@ -147,8 +147,10 @@ static Object serializeComment(const CommentInfo &I, Object &Description) { Child.insert({"ParamName", I.ParamName}); Child.insert({"Direction", I.Direction}); Child.insert({"Explicit", I.Explicit}); - Child.insert({"Children", ChildArr}); - Obj.insert({commentKindToString(I.Kind), ChildVal}); + auto TextCommentsArray = extractTextComments(CARef.front().getAsObject()); + Child.insert({"Children", TextCommentsArray}); + if (I.Kind == CommentKind::CK_ParamCommandComment) + insertComment(Description, ChildVal, "ParamComments"); 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 f2edb1b2eb9ac..d55a53194ee5c 100644 --- a/clang-tools-extra/clang-doc/assets/comment-template.mustache +++ b/clang-tools-extra/clang-doc/assets/comment-template.mustache @@ -24,6 +24,14 @@ {{>Comments}} {{/Children}} {{/ParagraphComment}} +{{#HasParamComments}} + <h3>Parameters</h3> + {{#ParamComments}} + <div> + <b>{{ParamName}}</b> {{#Explicit}}{{Direction}}{{/Explicit}} {{#Children}}{{>Comments}}{{/Children}} + </div> + {{/ParamComments}} +{{/HasParamComments}} {{#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 4cf8bad32fd9d..b55e0abe2cdef 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.mustache.test +++ b/clang-tools-extra/test/clang-doc/basic-project.mustache.test @@ -260,6 +260,23 @@ HTML-CALC: </div> HTML-CALC: <div> HTML-CALC: <p></p> HTML-CALC: </div> +HTML-CALC: <h3>Parameters</h3> +HTML-CALC: <div> +HTML-CALC: <b>a</b> <div> +HTML-CALC: <p> First integer.</p> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <p></p> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <b>b</b> <div> +HTML-CALC: <p> Second integer.</p> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <p></p> +HTML-CALC: </div> +HTML-CALC: </div> HTML-CALC: </div> HTML-CALC: </div> HTML-CALC: </div> @@ -300,6 +317,23 @@ HTML-CALC: </div> HTML-CALC: <div> HTML-CALC: <p></p> HTML-CALC: </div> +HTML-CALC: <h3>Parameters</h3> +HTML-CALC: <div> +HTML-CALC: <b>a</b> <div> +HTML-CALC: <p> First integer.</p> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <p></p> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <b>b</b> <div> +HTML-CALC: <p> Second integer.</p> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <p></p> +HTML-CALC: </div> +HTML-CALC: </div> HTML-CALC: </div> HTML-CALC: </div> HTML-CALC: </div> @@ -320,6 +354,23 @@ HTML-CALC: </div> HTML-CALC: <div> HTML-CALC: <p></p> HTML-CALC: </div> +HTML-CALC: <h3>Parameters</h3> +HTML-CALC: <div> +HTML-CALC: <b>a</b> <div> +HTML-CALC: <p> First integer.</p> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <p></p> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <b>b</b> <div> +HTML-CALC: <p> Second integer.</p> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <p></p> +HTML-CALC: </div> +HTML-CALC: </div> HTML-CALC: </div> HTML-CALC: </div> HTML-CALC: </div> @@ -340,6 +391,23 @@ HTML-CALC: </div> HTML-CALC: <div> HTML-CALC: <p></p> HTML-CALC: </div> +HTML-CALC: <h3>Parameters</h3> +HTML-CALC: <div> +HTML-CALC: <b>a</b> <div> +HTML-CALC: <p> First integer.</p> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <p></p> +HTML-CALC: </div> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <b>b</b> <div> +HTML-CALC: <p> Second integer.</p> +HTML-CALC: </div> +HTML-CALC: <div> +HTML-CALC: <p></p> +HTML-CALC: </div> +HTML-CALC: </div> HTML-CALC: </div> HTML-CALC: </div> HTML-CALC: </div> @@ -439,6 +507,20 @@ HTML-RECTANGLE: </div> HTML-RECTANGLE: <div> HTML-RECTANGLE: <p></p> HTML-RECTANGLE: </div> +HTML-RECTANGLE: <h3>Parameters</h3> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <b>width</b> <div> +HTML-RECTANGLE: <p> Width of the rectangle.</p> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <p></p> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: <div> +HTML-RECTANGLE: <b>height</b> <div> +HTML-RECTANGLE: <p> Height of the rectangle.</p> +HTML-RECTANGLE: </div> +HTML-RECTANGLE: </div> HTML-RECTANGLE: </div> HTML-RECTANGLE: </div> HTML-RECTANGLE: </div> @@ -578,6 +660,12 @@ HTML-CIRCLE: </div> HTML-CIRCLE: <div> HTML-CIRCLE: <p></p> HTML-CIRCLE: </div> +HTML-CIRCLE: <h3>Parameters</h3> +HTML-CIRCLE: <div> +HTML-CIRCLE: <b>radius</b> <div> +HTML-CIRCLE: <p> Radius of the circle.</p> +HTML-CIRCLE: </div> +HTML-CIRCLE: </div> HTML-CIRCLE: </div> HTML-CIRCLE: </div> HTML-CIRCLE: </div> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits