Author: Samrudh Nelli Date: 2026-03-10T08:34:52-07:00 New Revision: 7dc78ebedc62d38aad89a048d103ed323b010bef
URL: https://github.com/llvm/llvm-project/commit/7dc78ebedc62d38aad89a048d103ed323b010bef DIFF: https://github.com/llvm/llvm-project/commit/7dc78ebedc62d38aad89a048d103ed323b010bef.diff LOG: [Clang-doc] Trim comments after parsing them from the AST (#185528) Currently many comments parsed from the AST contain leading spaces. Trim the leading and trailing spaces before using them in clang-doc. Added: Modified: clang-tools-extra/clang-doc/MDGenerator.cpp clang-tools-extra/clang-doc/Serialize.cpp clang-tools-extra/clang-doc/assets/md/comments-partial.mustache clang-tools-extra/test/clang-doc/basic-project.mustache.test clang-tools-extra/test/clang-doc/basic-project.test clang-tools-extra/test/clang-doc/comments-in-macros.cpp clang-tools-extra/test/clang-doc/enum.cpp clang-tools-extra/test/clang-doc/json/class.cpp clang-tools-extra/test/clang-doc/json/compound-constraints.cpp clang-tools-extra/test/clang-doc/json/concept.cpp clang-tools-extra/test/clang-doc/namespace.cpp clang-tools-extra/test/clang-doc/templates.cpp clang-tools-extra/test/clang-doc/typedef-alias.cpp clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-doc/MDGenerator.cpp b/clang-tools-extra/clang-doc/MDGenerator.cpp index dee3c21f72a38..60a880d211884 100644 --- a/clang-tools-extra/clang-doc/MDGenerator.cpp +++ b/clang-tools-extra/clang-doc/MDGenerator.cpp @@ -88,7 +88,7 @@ static void writeDescription(const CommentInfo &I, raw_ostream &OS) { break; case CommentKind::CK_BlockCommandComment: - OS << genEmphasis(I.Name); + OS << genEmphasis(I.Name) << " "; for (const auto &Child : I.Children) writeDescription(*Child, OS); break; @@ -100,7 +100,7 @@ static void writeDescription(const CommentInfo &I, raw_ostream &OS) { case CommentKind::CK_ParamCommandComment: case CommentKind::CK_TParamCommandComment: { std::string Direction = I.Explicit ? (" " + I.Direction).str() : ""; - OS << genEmphasis(I.ParamName) << I.Text << Direction; + OS << genEmphasis(I.ParamName) << I.Text << Direction << " "; for (const auto &Child : I.Children) writeDescription(*Child, OS); break; diff --git a/clang-tools-extra/clang-doc/Serialize.cpp b/clang-tools-extra/clang-doc/Serialize.cpp index 7b09c1ea29b50..14c8fcca25abd 100644 --- a/clang-tools-extra/clang-doc/Serialize.cpp +++ b/clang-tools-extra/clang-doc/Serialize.cpp @@ -239,14 +239,14 @@ void ClangDocCommentVisitor::parseComment(const comments::Comment *C) { void ClangDocCommentVisitor::visitTextComment(const TextComment *C) { if (!isWhitespaceOnly(C->getText())) - CurrentCI.Text = C->getText(); + CurrentCI.Text = C->getText().trim(); } void ClangDocCommentVisitor::visitInlineCommandComment( const InlineCommandComment *C) { CurrentCI.Name = getCommandName(C->getCommandID()); for (unsigned I = 0, E = C->getNumArgs(); I != E; ++I) - CurrentCI.Args.push_back(C->getArgText(I)); + CurrentCI.Args.push_back(C->getArgText(I).trim()); } void ClangDocCommentVisitor::visitHTMLStartTagComment( @@ -270,7 +270,7 @@ void ClangDocCommentVisitor::visitBlockCommandComment( const BlockCommandComment *C) { CurrentCI.Name = getCommandName(C->getCommandID()); for (unsigned I = 0, E = C->getNumArgs(); I < E; ++I) - CurrentCI.Args.push_back(C->getArgText(I)); + CurrentCI.Args.push_back(C->getArgText(I).trim()); } void ClangDocCommentVisitor::visitParamCommandComment( diff --git a/clang-tools-extra/clang-doc/assets/md/comments-partial.mustache b/clang-tools-extra/clang-doc/assets/md/comments-partial.mustache index e0719d7a7baca..1f21f98803c18 100644 --- a/clang-tools-extra/clang-doc/assets/md/comments-partial.mustache +++ b/clang-tools-extra/clang-doc/assets/md/comments-partial.mustache @@ -1,6 +1,6 @@ {{#HasBriefComments}} {{#BriefComments}} -**brief**{{#.}}{{TextComment}}{{/.}} +**brief** {{#.}}{{TextComment}}{{/.}} {{/BriefComments}} {{/HasBriefComments}} 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 c94008f7bdf36..0b190caeed8f5 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.mustache.test +++ b/clang-tools-extra/test/clang-doc/basic-project.mustache.test @@ -63,10 +63,10 @@ HTML-SHAPE-NEXT: <h1 class="hero__title-large">class Shape</ HTML-SHAPE-NEXT: <p>Defined at line {{[0-9]+}} of file {{.*}}include{{[\/]}}Shape.h</p> HTML-SHAPE-NEXT: <div class="doc-card"> HTML-SHAPE-NEXT: <div class="nested-delimiter-container"> -HTML-SHAPE-NEXT: <p> Abstract base class for shapes.</p> +HTML-SHAPE-NEXT: <p>Abstract base class for shapes.</p> HTML-SHAPE-NEXT: </div> HTML-SHAPE-NEXT: <div class="nested-delimiter-container"> -HTML-SHAPE-NEXT: <p> Provides a common interface for diff erent types of shapes.</p> +HTML-SHAPE-NEXT: <p>Provides a common interface for diff erent types of shapes.</p> HTML-SHAPE-NEXT: </div> HTML-SHAPE-NEXT: </div> HTML-SHAPE-NEXT: </div> @@ -77,11 +77,11 @@ HTML-SHAPE-LABEL: <div id="{{([0-9A-F]{40})}}" class="deli HTML-SHAPE-NEXT: <pre><code class="language-cpp code-clang-doc">double area ()</code></pre> HTML-SHAPE-NEXT: <div class="doc-card"> HTML-SHAPE-NEXT: <div class="nested-delimiter-container"> -HTML-SHAPE-NEXT: <p> Calculates the area of the shape.</p> +HTML-SHAPE-NEXT: <p>Calculates the area of the shape.</p> HTML-SHAPE-NEXT: </div> HTML-SHAPE-NEXT: <div class="nested-delimiter-container"> HTML-SHAPE-NEXT: <h3>Returns</h3> -HTML-SHAPE-NEXT: <p> double The area of the shape.</p> +HTML-SHAPE-NEXT: <p>double The area of the shape.</p> HTML-SHAPE-NEXT: </div> HTML-SHAPE-NEXT: </div> HTML-SHAPE-NEXT: </div> @@ -89,11 +89,11 @@ HTML-SHAPE-LABEL: <div id="{{([0-9A-F]{40})}}" class="del HTML-SHAPE-NEXT: <pre><code class="language-cpp code-clang-doc">double perimeter ()</code></pre> HTML-SHAPE-NEXT: <div class="doc-card"> HTML-SHAPE-NEXT: <div class="nested-delimiter-container"> -HTML-SHAPE-NEXT: <p> Calculates the perimeter of the shape.</p> +HTML-SHAPE-NEXT: <p>Calculates the perimeter of the shape.</p> HTML-SHAPE-NEXT: </div> HTML-SHAPE-NEXT: <div class="nested-delimiter-container"> HTML-SHAPE-NEXT: <h3>Returns</h3> -HTML-SHAPE-NEXT: <p> double The perimeter of the shape.</p> +HTML-SHAPE-NEXT: <p>double The perimeter of the shape.</p> HTML-SHAPE-NEXT: </div> HTML-SHAPE-NEXT: </div> HTML-SHAPE-NEXT: </div> @@ -101,7 +101,7 @@ HTML-SHAPE-LABEL: <div id="{{([0-9A-F]{40})}}" class="del HTML-SHAPE-NEXT: <pre><code class="language-cpp code-clang-doc">void ~Shape ()</code></pre> HTML-SHAPE-NEXT: <div class="doc-card"> HTML-SHAPE-NEXT: <div class="nested-delimiter-container"> -HTML-SHAPE-NEXT: <p> Virtual destructor.</p> +HTML-SHAPE-NEXT: <p>Virtual destructor.</p> HTML-SHAPE-NEXT: </div> HTML-SHAPE-NEXT: </div> HTML-SHAPE-NEXT: <p>Defined at line {{[0-9]+}} of file {{.*}}include{{[/\\]}}Shape.h</p> @@ -183,10 +183,10 @@ HTML-CALC-NEXT: <h1 class="hero__title-large">class Calculat HTML-CALC-NEXT: <p>Defined at line {{[0-9]+}} of file {{.*}}include{{[/\\]}}Calculator.h</p> HTML-CALC-NEXT: <div class="doc-card"> HTML-CALC-NEXT: <div class="nested-delimiter-container"> -HTML-CALC-NEXT: <p> A simple calculator class.</p> +HTML-CALC-NEXT: <p>A simple calculator class.</p> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <div class="nested-delimiter-container"> -HTML-CALC-NEXT: <p> Provides basic arithmetic operations.</p> +HTML-CALC-NEXT: <p>Provides basic arithmetic operations.</p> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: </div> @@ -208,7 +208,7 @@ HTML-CALC-LABEL: <div id="{{([0-9A-F]{40})}}" class="delimiter-co HTML-CALC-NEXT: <pre><code class="language-cpp code-clang-doc">int add (int a, int b)</code></pre> HTML-CALC-NEXT: <div class="doc-card"> HTML-CALC-NEXT: <div class="nested-delimiter-container"> -HTML-CALC-NEXT: <p> Adds two integers.</p> +HTML-CALC-NEXT: <p>Adds two integers.</p> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <div class="nested-delimiter-container"> HTML-CALC-NEXT: <h3>Parameters</h3> @@ -221,14 +221,14 @@ HTML-CALC-NEXT: </div> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <div class="nested-delimiter-container"> HTML-CALC-NEXT: <h3>Returns</h3> -HTML-CALC-NEXT: <p> int The sum of a and b.</p> +HTML-CALC-NEXT: <p>int The sum of a and b.</p> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: </div> HTML-CALC-LABEL: <div id="{{([0-9A-F]{40})}}" class="delimiter-container"> HTML-CALC-NEXT: <pre><code class="language-cpp code-clang-doc">int subtract (int a, int b)</code></pre> HTML-CALC-NEXT: <div class="doc-card"> HTML-CALC-NEXT: <div class="nested-delimiter-container"> -HTML-CALC-NEXT: <p> Subtracts the second integer from the first.</p> +HTML-CALC-NEXT: <p>Subtracts the second integer from the first.</p> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <div class="nested-delimiter-container"> HTML-CALC-NEXT: <h3>Parameters</h3> @@ -241,14 +241,14 @@ HTML-CALC-NEXT: </div> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <div class="nested-delimiter-container"> HTML-CALC-NEXT: <h3>Returns</h3> -HTML-CALC-NEXT: <p> int The result of a - b.</p> +HTML-CALC-NEXT: <p>int The result of a - b.</p> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: </div> HTML-CALC-LABEL: <div id="{{([0-9A-F]{40})}}" class="delimiter-container"> HTML-CALC-NEXT: <pre><code class="language-cpp code-clang-doc">int multiply (int a, int b)</code></pre> HTML-CALC-NEXT: <div class="doc-card"> HTML-CALC-NEXT: <div class="nested-delimiter-container"> -HTML-CALC-NEXT: <p> Multiplies two integers.</p> +HTML-CALC-NEXT: <p>Multiplies two integers.</p> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <div class="nested-delimiter-container"> HTML-CALC-NEXT: <h3>Parameters</h3> @@ -261,14 +261,14 @@ HTML-CALC-NEXT: </div> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <div class="nested-delimiter-container"> HTML-CALC-NEXT: <h3>Returns</h3> -HTML-CALC-NEXT: <p> int The product of a and b.</p> +HTML-CALC-NEXT: <p>int The product of a and b.</p> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: </div> HTML-CALC-LABEL: <div id="{{([0-9A-F]{40})}}" class="delimiter-container"> HTML-CALC-NEXT: <pre><code class="language-cpp code-clang-doc">double divide (int a, int b)</code></pre> HTML-CALC-NEXT: <div class="doc-card"> HTML-CALC-NEXT: <div class="nested-delimiter-container"> -HTML-CALC-NEXT: <p> Divides the first integer by the second.</p> +HTML-CALC-NEXT: <p>Divides the first integer by the second.</p> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <div class="nested-delimiter-container"> HTML-CALC-NEXT: <h3>Parameters</h3> @@ -281,7 +281,7 @@ HTML-CALC-NEXT: </div> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <div class="nested-delimiter-container"> HTML-CALC-NEXT: <h3>Returns</h3> -HTML-CALC-NEXT: <p> double The result of a / b.</p> +HTML-CALC-NEXT: <p>double The result of a / b.</p> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <div class="nested-delimiter-container"> HTML-CALC-NEXT: <h3>Throws</h3> @@ -294,7 +294,7 @@ HTML-CALC-LABEL: <div id="{{([0-9A-F]{40})}}" class="delimiter-co HTML-CALC-NEXT: <pre><code class="language-cpp code-clang-doc">int mod (int a, int b)</code></pre> HTML-CALC-NEXT: <div class="doc-card"> HTML-CALC-NEXT: <div class="nested-delimiter-container"> -HTML-CALC-NEXT: <p> Performs the mod operation on integers.</p> +HTML-CALC-NEXT: <p>Performs the mod operation on integers.</p> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <div class="nested-delimiter-container"> HTML-CALC-NEXT: <h3>Parameters</h3> @@ -307,7 +307,7 @@ HTML-CALC-NEXT: </div> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <div class="nested-delimiter-container"> HTML-CALC-NEXT: <h3>Returns</h3> -HTML-CALC-NEXT: <p> The result of a % b.</p> +HTML-CALC-NEXT: <p>The result of a % b.</p> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: </div> HTML-CALC-NEXT: <p>Defined at line {{[0-9]+}} of file {{.*}}include{{[/\\]}}Calculator.h</p> @@ -368,10 +368,10 @@ HTML-RECTANGLE-NEXT: <h1 class="hero__title-large">class Rec HTML-RECTANGLE-NEXT: <p>Defined at line {{[0-9]+}} of file {{.*}}include{{[/\\]}}Rectangle.h</p> HTML-RECTANGLE-NEXT: <div class="doc-card"> HTML-RECTANGLE-NEXT: <div class="nested-delimiter-container"> -HTML-RECTANGLE-NEXT: <p> Rectangle class derived from Shape.</p> +HTML-RECTANGLE-NEXT: <p>Rectangle class derived from Shape.</p> HTML-RECTANGLE-NEXT: </div> HTML-RECTANGLE-NEXT: <div class="nested-delimiter-container"> -HTML-RECTANGLE-NEXT: <p> Represents a rectangle with a given width and height.</p> +HTML-RECTANGLE-NEXT: <p>Represents a rectangle with a given width and height.</p> HTML-RECTANGLE-NEXT: </div> HTML-RECTANGLE-NEXT: </div> HTML-RECTANGLE-NEXT: </div> @@ -382,7 +382,7 @@ HTML-RECTANGLE-LABEL: <div id="{{([0-9A-F]{40})}}" class="delimit HTML-RECTANGLE-NEXT: <pre><code class="language-cpp code-clang-doc">void Rectangle (double width, double height)</code></pre> HTML-RECTANGLE-NEXT: <div class="doc-card"> HTML-RECTANGLE-NEXT: <div class="nested-delimiter-container"> -HTML-RECTANGLE-NEXT: <p> Constructs a new Rectangle object.</p> +HTML-RECTANGLE-NEXT: <p>Constructs a new Rectangle object.</p> HTML-RECTANGLE-NEXT: </div> HTML-RECTANGLE-NEXT: <div class="nested-delimiter-container"> HTML-RECTANGLE-NEXT: <h3>Parameters</h3> @@ -398,22 +398,22 @@ HTML-RECTANGLE-LABEL: <div id="{{([0-9A-F]{40})}}" class="delimit HTML-RECTANGLE-NEXT: <pre><code class="language-cpp code-clang-doc">double area ()</code></pre> HTML-RECTANGLE-NEXT: <div class="doc-card"> HTML-RECTANGLE-NEXT: <div class="nested-delimiter-container"> -HTML-RECTANGLE-NEXT: <p> Calculates the area of the rectangle.</p> +HTML-RECTANGLE-NEXT: <p>Calculates the area of the rectangle.</p> HTML-RECTANGLE-NEXT: </div> HTML-RECTANGLE-NEXT: <div class="nested-delimiter-container"> HTML-RECTANGLE-NEXT: <h3>Returns</h3> -HTML-RECTANGLE-NEXT: <p> double The area of the rectangle.</p> +HTML-RECTANGLE-NEXT: <p>double The area of the rectangle.</p> HTML-RECTANGLE-NEXT: </div> HTML-RECTANGLE-NEXT: </div> HTML-RECTANGLE-LABEL: <div id="{{([0-9A-F]{40})}}" class="delimiter-container"> HTML-RECTANGLE-NEXT: <pre><code class="language-cpp code-clang-doc">double perimeter ()</code></pre> HTML-RECTANGLE-NEXT: <div class="doc-card"> HTML-RECTANGLE-NEXT: <div class="nested-delimiter-container"> -HTML-RECTANGLE-NEXT: <p> Calculates the perimeter of the rectangle.</p> +HTML-RECTANGLE-NEXT: <p>Calculates the perimeter of the rectangle.</p> HTML-RECTANGLE-NEXT: </div> HTML-RECTANGLE-NEXT: <div class="nested-delimiter-container"> HTML-RECTANGLE-NEXT: <h3>Returns</h3> -HTML-RECTANGLE-NEXT: <p> double The perimeter of the rectangle.</p> +HTML-RECTANGLE-NEXT: <p>double The perimeter of the rectangle.</p> HTML-RECTANGLE-NEXT: </div> HTML-RECTANGLE-NEXT: </div> HTML-RECTANGLE-NEXT: <p>Defined at line {{[0-9]+}} of file {{.*}}src{{[/\\]}}Rectangle.cpp</p> @@ -474,10 +474,10 @@ HTML-CIRCLE-NEXT: <h1 class="hero__title-large">class Circle HTML-CIRCLE-NEXT: <p>Defined at line {{[0-9]+}} of file {{.*}}include{{[/\\]}}Circle.h</p> HTML-CIRCLE-NEXT: <div class="doc-card"> HTML-CIRCLE-NEXT: <div class="nested-delimiter-container"> -HTML-CIRCLE-NEXT: <p> Circle class derived from Shape.</p> +HTML-CIRCLE-NEXT: <p>Circle class derived from Shape.</p> HTML-CIRCLE-NEXT: </div> HTML-CIRCLE-NEXT: <div class="nested-delimiter-container"> -HTML-CIRCLE-NEXT: <p> Represents a circle with a given radius.</p> +HTML-CIRCLE-NEXT: <p>Represents a circle with a given radius.</p> HTML-CIRCLE-NEXT: </div> HTML-CIRCLE-NEXT: </div> HTML-CIRCLE-NEXT: </div> @@ -488,7 +488,7 @@ HTML-CIRCLE-LABEL: <div id="{{([0-9A-F]{40})}}" class="delimiter- HTML-CIRCLE-NEXT: <pre><code class="language-cpp code-clang-doc">void Circle (double radius)</code></pre> HTML-CIRCLE-NEXT: <div class="doc-card"> HTML-CIRCLE-NEXT: <div class="nested-delimiter-container"> -HTML-CIRCLE-NEXT: <p> Constructs a new Circle object.</p> +HTML-CIRCLE-NEXT: <p>Constructs a new Circle object.</p> HTML-CIRCLE-NEXT: </div> HTML-CIRCLE-NEXT: <div class="nested-delimiter-container"> HTML-CIRCLE-NEXT: <h3>Parameters</h3> @@ -501,22 +501,22 @@ HTML-CIRCLE-LABEL: <div id="{{([0-9A-F]{40})}}" class="delimiter- HTML-CIRCLE-NEXT: <pre><code class="language-cpp code-clang-doc">double area ()</code></pre> HTML-CIRCLE-NEXT: <div class="doc-card"> HTML-CIRCLE-NEXT: <div class="nested-delimiter-container"> -HTML-CIRCLE-NEXT: <p> Calculates the area of the circle.</p> +HTML-CIRCLE-NEXT: <p>Calculates the area of the circle.</p> HTML-CIRCLE-NEXT: </div> HTML-CIRCLE-NEXT: <div class="nested-delimiter-container"> HTML-CIRCLE-NEXT: <h3>Returns</h3> -HTML-CIRCLE-NEXT: <p> double The area of the circle.</p> +HTML-CIRCLE-NEXT: <p>double The area of the circle.</p> HTML-CIRCLE-NEXT: </div> HTML-CIRCLE-NEXT: </div> HTML-CIRCLE-LABEL: <div id="{{([0-9A-F]{40})}}" class="delimiter-container"> HTML-CIRCLE-NEXT: <pre><code class="language-cpp code-clang-doc">double perimeter ()</code></pre> HTML-CIRCLE-NEXT: <div class="doc-card"> HTML-CIRCLE-NEXT: <div class="nested-delimiter-container"> -HTML-CIRCLE-NEXT: <p> Calculates the perimeter of the circle.</p> +HTML-CIRCLE-NEXT: <p>Calculates the perimeter of the circle.</p> HTML-CIRCLE-NEXT: </div> HTML-CIRCLE-NEXT: <div class="nested-delimiter-container"> HTML-CIRCLE-NEXT: <h3>Returns</h3> -HTML-CIRCLE-NEXT: <p> double The perimeter of the circle.</p> +HTML-CIRCLE-NEXT: <p>double The perimeter of the circle.</p> HTML-CIRCLE-NEXT: </div> HTML-CIRCLE-NEXT: <h3>Code</h3> HTML-CIRCLE-NEXT: <div> diff --git a/clang-tools-extra/test/clang-doc/basic-project.test b/clang-tools-extra/test/clang-doc/basic-project.test index 9220dc6974508..057091102f122 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.test +++ b/clang-tools-extra/test/clang-doc/basic-project.test @@ -92,7 +92,7 @@ // MD-CALC: **a** First integer. // MD-CALC: **b** Second integer. // MD-CALC: **return** double The result of a / b. -// MD-CALC: **throw**if b is zero. +// MD-CALC: **throw** if b is zero. // MD-CALC: ### mod // MD-CALC: *public static int mod(int a, int b)* // MD-CALC: *Defined at ./include{{[\/]}}Calculator.h#54* diff --git a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp index 20bbf4cd087c0..7200800e82acc 100644 --- a/clang-tools-extra/test/clang-doc/comments-in-macros.cpp +++ b/clang-tools-extra/test/clang-doc/comments-in-macros.cpp @@ -30,7 +30,7 @@ // HTML-MYCLASS: <pre><code class="language-cpp code-clang-doc">int Add (int a, int b)</code></pre> // HTML-MYCLASS: <div class="doc-card"> // HTML-MYCLASS: <div class="nested-delimiter-container"> -// HTML-MYCLASS: <p> Declare a method to calculate the sum of two numbers</p> +// HTML-MYCLASS: <p>Declare a method to calculate the sum of two numbers</p> // HTML-MYCLASS: </div> class MyClass { diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp index b0c4257bb746e..c5f939550320d 100644 --- a/clang-tools-extra/test/clang-doc/enum.cpp +++ b/clang-tools-extra/test/clang-doc/enum.cpp @@ -74,7 +74,7 @@ enum Color { // HTML-INDEX-NEXT: </table> // HTML-INDEX-NEXT: <div class="doc-card"> // HTML-INDEX-NEXT: <div class="nested-delimiter-container"> -// HTML-INDEX-NEXT: <p> For specifying RGB colors</p> +// HTML-INDEX-NEXT: <p>For specifying RGB colors</p> // HTML-INDEX-NEXT: </div> // HTML-INDEX-NEXT: </div> // HTML-INDEX-NEXT: <p>Defined at line [[@LINE-46]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> @@ -136,7 +136,7 @@ enum class Shapes { // HTML-INDEX-NEXT: </table> // HTML-INDEX-NEXT: <div class="doc-card"> // HTML-INDEX-NEXT: <div class="nested-delimiter-container"> -// HTML-INDEX-NEXT: <p> Shape Types</p> +// HTML-INDEX-NEXT: <p>Shape Types</p> // HTML-INDEX-NEXT: </div> // HTML-INDEX-NEXT: </div> // HTML-INDEX-NEXT: <p>Defined at line [[@LINE-48]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> @@ -187,7 +187,7 @@ enum Size : uint8_t { // HTML-INDEX-NEXT: </table> // HTML-INDEX-NEXT: <div class="doc-card"> // HTML-INDEX-NEXT: <div class="nested-delimiter-container"> -// HTML-INDEX-NEXT: <p> Specify the size</p> +// HTML-INDEX-NEXT: <p>Specify the size</p> // HTML-INDEX-NEXT: </div> // HTML-INDEX-NEXT: </div> // HTML-INDEX-NEXT: <p>Defined at line [[@LINE-44]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> @@ -225,7 +225,7 @@ enum : long long { // HTML-INDEX-NEXT: </table> // HTML-INDEX-NEXT: <div class="doc-card"> // HTML-INDEX-NEXT: <div class="nested-delimiter-container"> -// HTML-INDEX-NEXT: <p> Very long number</p> +// HTML-INDEX-NEXT: <p>Very long number</p> // HTML-INDEX-NEXT: </div> // HTML-INDEX-NEXT: </div> // HTML-INDEX-NEXT: <p>Defined at line [[@LINE-32]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> @@ -282,7 +282,7 @@ class FilePermissions { // HTML-PERM-NEXT: </table> // HTML-PERM-NEXT: <div class="doc-card"> // HTML-PERM-NEXT: <div class="nested-delimiter-container"> -// HTML-PERM-NEXT: <p> File permission flags</p> +// HTML-PERM-NEXT: <p>File permission flags</p> // HTML-PERM-NEXT: </div> // HTML-PERM-NEXT: </div> // HTML-PERM-NEXT: <p>Defined at line [[@LINE-47]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> @@ -336,7 +336,7 @@ class Animals { // HTML-ANIMAL-NEXT: </table> // HTML-ANIMAL-NEXT: <div class="doc-card"> // HTML-ANIMAL-NEXT: <div class="nested-delimiter-container"> -// HTML-ANIMAL-NEXT: <p> specify what animal the class is</p> +// HTML-ANIMAL-NEXT: <p>specify what animal the class is</p> // HTML-ANIMAL-NEXT: </div> // HTML-ANIMAL-NEXT: </div> // HTML-ANIMAL-NEXT: <p>Defined at line [[@LINE-41]] of file {{.*}}enum.cpp</p> @@ -417,7 +417,7 @@ enum Car { // HTML-VEHICLES-NEXT: </table> // HTML-VEHICLES-NEXT: <div class="doc-card"> // HTML-VEHICLES-NEXT: <div class="nested-delimiter-container"> -// HTML-VEHICLES-NEXT: <p> specify type of car</p> +// HTML-VEHICLES-NEXT: <p>specify type of car</p> // HTML-VEHICLES-NEXT: </div> // HTML-VEHICLES-NEXT: </div> // HTML-VEHICLES-NEXT: <p>Defined at line [[@LINE-55]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p> diff --git a/clang-tools-extra/test/clang-doc/json/class.cpp b/clang-tools-extra/test/clang-doc/json/class.cpp index 3bb9f5e6ec6bb..85f1508529f21 100644 --- a/clang-tools-extra/test/clang-doc/json/class.cpp +++ b/clang-tools-extra/test/clang-doc/json/class.cpp @@ -52,16 +52,16 @@ struct MyClass { // CHECK-NEXT: "BriefComments": [ // CHECK-NEXT: [ // CHECK-NEXT: { -// CHECK-NEXT: "TextComment": " This is a brief description." +// CHECK-NEXT: "TextComment": "This is a brief description." // CHECK: "HasBriefComments": true, // CHECK-NEXT: "HasParagraphComments": true, // CHECK-NEXT: "ParagraphComments": [ // CHECK-NEXT: [ // CHECK-NEXT: { -// CHECK-NEXT: "TextComment": " This is a nice class." +// CHECK-NEXT: "TextComment": "This is a nice class." // CHECK-NEXT: }, // CHECK-NEXT: { -// CHECK-NEXT: "TextComment": " It has some nice methods and fields." +// CHECK-NEXT: "TextComment": "It has some nice methods and fields." // CHECK-NEXT: } // CHECK: "DocumentationFileName": "_ZTV7MyClass", // CHECK: "Enums": [ @@ -103,7 +103,7 @@ struct MyClass { // CHECK-NEXT: "ParagraphComments": [ // CHECK-NEXT: [ // CHECK-NEXT: { -// CHECK-NEXT: "TextComment": " This is a function template friend." +// CHECK-NEXT: "TextComment": "This is a function template friend." // CHECK-NEXT: } // CHECK-NEXT: ] // CHECK-NEXT: ] @@ -149,7 +149,7 @@ struct MyClass { // CHECK-NEXT: "ParagraphComments": [ // CHECK-NEXT: [ // CHECK-NEXT: { -// CHECK-NEXT: "TextComment": " This is a struct friend." +// CHECK-NEXT: "TextComment": "This is a struct friend." // CHECK-NEXT: } // CHECK-NEXT: ] // CHECK-NEXT: ] diff --git a/clang-tools-extra/test/clang-doc/json/compound-constraints.cpp b/clang-tools-extra/test/clang-doc/json/compound-constraints.cpp index a34be9753f80e..97fe50b719792 100644 --- a/clang-tools-extra/test/clang-doc/json/compound-constraints.cpp +++ b/clang-tools-extra/test/clang-doc/json/compound-constraints.cpp @@ -149,7 +149,7 @@ template<typename T> requires (Incrementable<T> && Decrementable<T>) || PreIncre // CHECK-HTML-NEXT: <pre><code class="language-cpp code-clang-doc">template <typename T> Incrementable requires (T a) { a++; }</code></pre> // CHECK-HTML-NEXT: </div> // CHECK-HTML-NEXT: <div class="nested-delimiter-container"> -// CHECK-HTML-NEXT: <p> Concept for an incrementable value</p> +// CHECK-HTML-NEXT: <p>Concept for an incrementable value</p> // CHECK-HTML-NEXT: </div> // CHECK-HTML-NEXT: <h3>Template Parameters</h3> // CHECK-HTML-NEXT: <div class="nested-delimiter-container"> @@ -164,7 +164,7 @@ template<typename T> requires (Incrementable<T> && Decrementable<T>) || PreIncre // CHECK-HTML-NEXT: <pre><code class="language-cpp code-clang-doc">template <typename T> Decrementable requires (T a) { a--; }</code></pre> // CHECK-HTML-NEXT: </div> // CHECK-HTML-NEXT: <div class="nested-delimiter-container"> -// CHECK-HTML-NEXT: <p> Concept for a decrementable value</p> +// CHECK-HTML-NEXT: <p>Concept for a decrementable value</p> // CHECK-HTML-NEXT: </div> // CHECK-HTML-NEXT: <h3>Template Parameters</h3> // CHECK-HTML-NEXT: <div class="nested-delimiter-container"> @@ -179,7 +179,7 @@ template<typename T> requires (Incrementable<T> && Decrementable<T>) || PreIncre // CHECK-HTML-NEXT: <pre><code class="language-cpp code-clang-doc">template <typename T> PreIncrementable requires (T a) { ++a; }</code></pre> // CHECK-HTML-NEXT: </div> // CHECK-HTML-NEXT: <div class="nested-delimiter-container"> -// CHECK-HTML-NEXT: <p> Concept for a pre-incrementable value</p> +// CHECK-HTML-NEXT: <p>Concept for a pre-incrementable value</p> // CHECK-HTML-NEXT: </div> // CHECK-HTML-NEXT: <h3>Template Parameters</h3> // CHECK-HTML-NEXT: <div class="nested-delimiter-container"> @@ -194,7 +194,7 @@ template<typename T> requires (Incrementable<T> && Decrementable<T>) || PreIncre // CHECK-HTML-NEXT: <pre><code class="language-cpp code-clang-doc">template <typename T> PreDecrementable requires (T a) { --a; }</code></pre> // CHECK-HTML-NEXT: </div> // CHECK-HTML-NEXT: <div class="nested-delimiter-container"> -// CHECK-HTML-NEXT: <p> Concept for a -pre-decrementable value</p> +// CHECK-HTML-NEXT: <p>Concept for a -pre-decrementable value</p> // CHECK-HTML-NEXT: </div> // CHECK-HTML-NEXT: <h3>Template Parameters</h3> // CHECK-HTML-NEXT: <div class="nested-delimiter-container"> diff --git a/clang-tools-extra/test/clang-doc/json/concept.cpp b/clang-tools-extra/test/clang-doc/json/concept.cpp index 70d20be1096e8..764f173bb03bc 100644 --- a/clang-tools-extra/test/clang-doc/json/concept.cpp +++ b/clang-tools-extra/test/clang-doc/json/concept.cpp @@ -18,7 +18,7 @@ concept Incrementable = requires(T x) { // CHECK-NEXT: "ParagraphComments": [ // CHECK-NEXT: [ // CHECK-NEXT: { -// CHECK-NEXT: "TextComment": " Requires that T suports post and pre-incrementing." +// CHECK-NEXT: "TextComment": "Requires that T suports post and pre-incrementing." // CHECK: "End": true, // CHECK-NEXT: "InfoType": "concept", // CHECK-NEXT: "IsType": true, diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp b/clang-tools-extra/test/clang-doc/namespace.cpp index 1d7337d60f69c..e39fbacb62638 100644 --- a/clang-tools-extra/test/clang-doc/namespace.cpp +++ b/clang-tools-extra/test/clang-doc/namespace.cpp @@ -196,7 +196,7 @@ class ClassInNestedNamespace {}; // HTML-NESTED-INDEX: <pre><code class="language-cpp code-clang-doc">void functionInNestedNamespace ()</code></pre> // HTML-NESTED-INDEX: <div class="doc-card"> // HTML-NESTED-INDEX: <div class="nested-delimiter-container"> -// HTML-NESTED-INDEX: <p> Function in NestedNamespace</p> +// HTML-NESTED-INDEX: <p>Function in NestedNamespace</p> // HTML-NESTED-INDEX: </div> // HTML-NESTED-INDEX: </div> // HTML-NESTED-INDEX: <p>Defined at line [[@LINE-56]] of file {{.*}}namespace.cpp</p> @@ -241,7 +241,7 @@ class ClassInNestedNamespace {}; // HTML-PRIMARY-INDEX: <pre><code class="language-cpp code-clang-doc">void functionInPrimaryNamespace ()</code></pre> // HTML-PRIMARY-INDEX: <div class="doc-card"> // HTML-PRIMARY-INDEX: <div class="nested-delimiter-container"> -// HTML-PRIMARY-INDEX: <p> Function in PrimaryNamespace</p> +// HTML-PRIMARY-INDEX: <p>Function in PrimaryNamespace</p> // HTML-PRIMARY-INDEX: </div> // HTML-PRIMARY-INDEX: </div> // HTML-PRIMARY-INDEX: <p>Defined at line [[@LINE-130]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p> @@ -321,7 +321,7 @@ class ClassInAnotherNamespace {}; // HTML-ANOTHER-INDEX: <pre><code class="language-cpp code-clang-doc">void functionInAnotherNamespace ()</code></pre> // HTML-ANOTHER-INDEX: <div class="doc-card"> // HTML-ANOTHER-INDEX: <div class="nested-delimiter-container"> -// HTML-ANOTHER-INDEX: <p> Function in AnotherNamespace</p> +// HTML-ANOTHER-INDEX: <p>Function in AnotherNamespace</p> // HTML-ANOTHER-INDEX: </div> // HTML-ANOTHER-INDEX: </div> // HTML-ANOTHER-INDEX: <p>Defined at line [[@LINE-55]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p> diff --git a/clang-tools-extra/test/clang-doc/templates.cpp b/clang-tools-extra/test/clang-doc/templates.cpp index e7b003670fbf6..86af599472894 100644 --- a/clang-tools-extra/test/clang-doc/templates.cpp +++ b/clang-tools-extra/test/clang-doc/templates.cpp @@ -388,10 +388,10 @@ struct tuple {}; // HTML-STRUCT-NEXT: <p>Defined at line [[# @LINE - 6]] of file {{.*}}templates.cpp</p> // HTML-STRUCT-NEXT: <div class="doc-card"> // HTML-STRUCT-NEXT: <div class="nested-delimiter-container"> -// HTML-STRUCT-NEXT: <p> A Tuple type</p> +// HTML-STRUCT-NEXT: <p>A Tuple type</p> // HTML-STRUCT-NEXT: </div> // HTML-STRUCT-NEXT: <div class="nested-delimiter-container"> -// HTML-STRUCT-NEXT: <p> Does Tuple things.</p> +// HTML-STRUCT-NEXT: <p>Does Tuple things.</p> // HTML-STRUCT-NEXT: </div> // HTML-STRUCT-NEXT: </div> // HTML-STRUCT-NEXT: </div> @@ -410,7 +410,7 @@ tuple<int, int, bool> func_with_tuple_param(tuple<int, int, bool> t) { return t; // YAML-NEXT: - Kind: ParagraphComment // YAML-NEXT: Children: // YAML-NEXT: - Kind: TextComment -// YAML-NEXT: Text: ' A function with a tuple parameter' +// YAML-NEXT: Text: 'A function with a tuple parameter' // YAML-NEXT: - Kind: ParagraphComment // YAML-NEXT: Children: // YAML-NEXT: - Kind: TextComment @@ -421,7 +421,7 @@ tuple<int, int, bool> func_with_tuple_param(tuple<int, int, bool> t) { return t; // YAML-NEXT: - Kind: ParagraphComment // YAML-NEXT: Children: // YAML-NEXT: - Kind: TextComment -// YAML-NEXT: Text: ' The input to func_with_tuple_param' +// YAML-NEXT: Text: 'The input to func_with_tuple_param' // YAML-NEXT: DefLocation: // YAML-NEXT: LineNumber: [[# @LINE - 23]] // YAML-NEXT: Filename: @@ -472,7 +472,7 @@ tuple<int, int, bool> func_with_tuple_param(tuple<int, int, bool> t) { return t; // HTML: <pre><code class="language-cpp code-clang-doc">tuple<int, int, bool> func_with_tuple_param (tuple<int, int, bool> t)</code></pre> // HTML-NEXT: <div class="doc-card"> // HTML-NEXT: <div class="nested-delimiter-container"> -// HTML-NEXT: <p> A function with a tuple parameter</p> +// HTML-NEXT: <p>A function with a tuple parameter</p> // HTML-NEXT: </div> // HTML-NEXT: <div class="nested-delimiter-container"> // HTML-NEXT: <h3>Parameters</h3> diff --git a/clang-tools-extra/test/clang-doc/typedef-alias.cpp b/clang-tools-extra/test/clang-doc/typedef-alias.cpp index f5b4afd7ff6a8..c4dad4c25f2e0 100644 --- a/clang-tools-extra/test/clang-doc/typedef-alias.cpp +++ b/clang-tools-extra/test/clang-doc/typedef-alias.cpp @@ -41,14 +41,14 @@ using IntVec = Vector<int>; // HTML-GLOBAL-NEXT: <div id="{{([0-9A-F]{40})}}" class="delimiter-container"> // HTML-GLOBAL-NEXT: <pre><code class="language-cpp code-clang-doc">using u_long = unsigned long</code></pre> // HTML-GLOBAL-NEXT: <div class="nested-delimiter-container"> -// HTML-GLOBAL-NEXT: <p> This is u_long</p> +// HTML-GLOBAL-NEXT: <p>This is u_long</p> // HTML-GLOBAL-NEXT: </div> // HTML-GLOBAL-NEXT: <p>Defined at line 8 of file {{.*}}typedef-alias.cpp</p> // HTML-GLOBAL-NEXT: </div> // HTML-GLOBAL-NEXT: <div id="{{([0-9A-F]{40})}}" class="delimiter-container"> // HTML-GLOBAL-NEXT: <pre><code class="language-cpp code-clang-doc">typedef IntPtr int *</code></pre> // HTML-GLOBAL-NEXT: <div class="nested-delimiter-container"> -// HTML-GLOBAL-NEXT: <p> This is IntPtr</p> +// HTML-GLOBAL-NEXT: <p>This is IntPtr</p> // HTML-GLOBAL-NEXT: </div> // HTML-GLOBAL-NEXT: <p>Defined at line 11 of file {{.*}}typedef-alias.cpp</p> // HTML-GLOBAL-NEXT: </div> @@ -75,7 +75,7 @@ using IntVec = Vector<int>; // HTML-VECTOR-NEXT: <div id="{{([0-9A-F]{40})}}" class="delimiter-container"> // HTML-VECTOR-NEXT: <pre><code class="language-cpp code-clang-doc">using Ptr = IntPtr</code></pre> // HTML-VECTOR-NEXT: <div class="nested-delimiter-container"> -// HTML-VECTOR-NEXT: <p> This is a Ptr</p> +// HTML-VECTOR-NEXT: <p>This is a Ptr</p> // HTML-VECTOR-NEXT: </div> // HTML-VECTOR-NEXT: <p>Defined at line 16 of file {{.*}}typedef-alias.cpp</p> // HTML-VECTOR-NEXT: </div> diff --git a/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp index 7d13437b91bd1..da22d00835126 100644 --- a/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp +++ b/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp @@ -290,7 +290,7 @@ TEST_F(MDGeneratorTest, emitCommentMD) { ParamOut->Children.back()->Children.emplace_back(allocatePtr<CommentInfo>()); ParamOut->Children.back()->Children.back()->Kind = CommentKind::CK_TextComment; - ParamOut->Children.back()->Children.back()->Text = " is a parameter."; + ParamOut->Children.back()->Children.back()->Text = "is a parameter."; Top.Children.emplace_back(allocatePtr<CommentInfo>()); CommentInfo *ParamIn = Top.Children.back().get(); @@ -301,8 +301,9 @@ TEST_F(MDGeneratorTest, emitCommentMD) { ParamIn->Children.back()->Kind = CommentKind::CK_ParagraphComment; ParamIn->Children.back()->Children.emplace_back(allocatePtr<CommentInfo>()); ParamIn->Children.back()->Children.back()->Kind = CommentKind::CK_TextComment; - ParamIn->Children.back()->Children.back()->Text = " is a parameter."; - ParamIn->Children.back()->Children.emplace_back(allocatePtr<CommentInfo>()); + ParamIn->Children.back()->Children.back()->Text = "is a parameter."; + ParamIn->Children.back()->Children.emplace_back( + std::make_unique<CommentInfo>()); ParamIn->Children.back()->Children.back()->Kind = CommentKind::CK_TextComment; Top.Children.emplace_back(allocatePtr<CommentInfo>()); @@ -351,7 +352,7 @@ TEST_F(MDGeneratorTest, emitCommentMD) { **J** is a parameter. -**return**void +**return** void )raw"; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
