From fb80d5deda69b5d9b20bf1eea2968bb0a82340d2 Mon Sep 17 00:00:00 2001 From: Erick Velez Date: Fri, 18 Jul 2025 12:04:20 -0700 Subject: [PATCH] [clang-doc] enable comments in class templates The Mustache basic project has comments in its headers but the comments were not serialized. Now we serialize @brief and paragraph comments for classes and add that output to the basic project test. --- .../clang-doc/assets/class-template.mustache | 4 +- .../assets/comment-template.mustache | 9 +++- .../clang-doc/basic-project.mustache.test | 43 +++++++++++++++++++ 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/clang-doc/assets/class-template.mustache b/clang-tools-extra/clang-doc/assets/class-template.mustache index a4077323f29e2..b1a7470f7c33a 100644 --- a/clang-tools-extra/clang-doc/assets/class-template.mustache +++ b/clang-tools-extra/clang-doc/assets/class-template.mustache @@ -128,11 +128,11 @@

{{TagType}} {{Name}}

- {{#RecordComments}} + {{#Description}}
{{>Comments}}
- {{/RecordComments}} + {{/Description}}
{{#HasPublicMembers}} diff --git a/clang-tools-extra/clang-doc/assets/comment-template.mustache b/clang-tools-extra/clang-doc/assets/comment-template.mustache index 723ace7a0eed1..b793bad55cf6c 100644 --- a/clang-tools-extra/clang-doc/assets/comment-template.mustache +++ b/clang-tools-extra/clang-doc/assets/comment-template.mustache @@ -5,11 +5,16 @@ This file defines templates for generating comments }} -{{#FullComment}} +{{#BriefComments}} {{#Children}} {{>Comments}} {{/Children}} -{{/FullComment}} +{{/BriefComments}} +{{#ParagraphComments}} + {{#Children}} + {{>Comments}} + {{/Children}} +{{/ParagraphComments}} {{#ParagraphComment}} {{#Children}} {{>Comments}} 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 4dd6f4165f65e..4fb38e2b32fcb 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.mustache.test +++ b/clang-tools-extra/test/clang-doc/basic-project.mustache.test @@ -60,6 +60,17 @@ HTML-SHAPE:
HTML-SHAPE:
HTML-SHAPE:
HTML-SHAPE:

class Shape

+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE:

Abstract base class for shapes.

+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE:

+HTML-SHAPE:
+HTML-SHAPE:
+HTML-SHAPE:

Provides a common interface for different types of shapes.

+HTML-SHAPE:
+HTML-SHAPE:
HTML-SHAPE:
HTML-SHAPE:
HTML-SHAPE:
@@ -172,6 +183,16 @@ HTML-CALC:
HTML-CALC:
HTML-CALC:
HTML-CALC:

class Calculator

+HTML-CALC:
+HTML-CALC:

A simple calculator class.

+HTML-CALC:
+HTML-CALC:
+HTML-CALC:

+HTML-CALC:
+HTML-CALC:
+HTML-CALC:

Provides basic arithmetic operations.

+HTML-CALC:
+HTML-CALC:
HTML-CALC:
HTML-CALC:
HTML-CALC:
@@ -300,6 +321,17 @@ HTML-RECTANGLE:
HTML-RECTANGLE:
HTML-RECTANGLE:
HTML-RECTANGLE:

class Rectangle

+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE:

Rectangle class derived from Shape.

+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE:

+HTML-RECTANGLE:
+HTML-RECTANGLE:
+HTML-RECTANGLE:

Represents a rectangle with a given width and height.

+HTML-RECTANGLE:
+HTML-RECTANGLE:
HTML-RECTANGLE:
HTML-RECTANGLE:
HTML-RECTANGLE:
@@ -395,6 +427,17 @@ HTML-CIRCLE:
HTML-CIRCLE:
HTML-CIRCLE:
HTML-CIRCLE:

class Circle

+HTML-CIRCLE:
+HTML-CIRCLE:
+HTML-CIRCLE:

Circle class derived from Shape.

+HTML-CIRCLE:
+HTML-CIRCLE:
+HTML-CIRCLE:

+HTML-CIRCLE:
+HTML-CIRCLE:
+HTML-CIRCLE:

Represents a circle with a given radius.

+HTML-CIRCLE:
+HTML-CIRCLE:
HTML-CIRCLE:
HTML-CIRCLE:
HTML-CIRCLE: