[clang-tools-extra] [clang-doc] add enum test (PR #97679)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 15 16:18:55 PDT 2024
https://github.com/PeterChou1 updated https://github.com/llvm/llvm-project/pull/97679
>From b5e0335199541225a1b0eb5eaf661cd4df55dbd7 Mon Sep 17 00:00:00 2001
From: PeterChou1 <peter.chou at mail.utoronto.ca>
Date: Thu, 4 Jul 2024 01:14:11 -0400
Subject: [PATCH 1/5] [clang-doc] add enum test
---
clang-tools-extra/test/clang-doc/enum.cpp | 38 +++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 clang-tools-extra/test/clang-doc/enum.cpp
diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp
new file mode 100644
index 0000000000000..2f25eaf4e44e2
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -0,0 +1,38 @@
+// RUN: clang-doc --format=html --doxygen --output=%t/docs --executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone %s
+// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html -check-prefix=HTML-INDEX
+// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md -check-prefix=MD-INDEX
+
+/**
+ * @brief For specifying RGB colors
+ */
+enum Color {
+ Red, // Red enums
+ Green, // Green enums
+ Blue // Blue enums
+};
+
+// HTML-INDEX: <h1>Global Namespace</h1>
+// HTML-INDEX: <h2 id="Enums">Enums</h2>
+// HTML-INDEX: <div>
+// HTML-INDEX: <h3 id="{{([0-9A-F]{40})}}">enum Color</h3>
+// HTML-INDEX: <ul>
+// HTML-INDEX: <li>Red</li>
+// HTML-INDEX: <li>Green</li>
+// HTML-INDEX: <li>Blue</li>
+// HTML-INDEX: </ul>
+// HTML-INDEX: <p>Defined at line 11 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
+// HTML-INDEX: <div>
+// HTML-INDEX: <div></div>
+// HTML-INDEX: </div>
+// HTML-INDEX: </div>
+
+// MD-INDEX: # Global Namespace
+// MD-INDEX: ## Enums
+// MD-INDEX: | enum Color |
+// MD-INDEX: --
+// MD-INDEX: | Red |
+// MD-INDEX: | Green |
+// MD-INDEX: | Blue |
+// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11*
+// MD-INDEX: **brief** For specifying RGB colors
\ No newline at end of file
>From c10f9d42c26e6d26833a35824216529ab25e7fe8 Mon Sep 17 00:00:00 2001
From: PeterChou1 <peter.chou at mail.utoronto.ca>
Date: Thu, 4 Jul 2024 01:53:19 -0400
Subject: [PATCH 2/5] [clang-doc] update defined at line
---
clang-tools-extra/test/clang-doc/enum.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp
index 2f25eaf4e44e2..1e7dd6e4c5b0c 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -21,7 +21,7 @@ enum Color {
// HTML-INDEX: <li>Green</li>
// HTML-INDEX: <li>Blue</li>
// HTML-INDEX: </ul>
-// HTML-INDEX: <p>Defined at line 11 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
+// HTML-INDEX: <p>Defined at line 9 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
// HTML-INDEX: <div>
// HTML-INDEX: <div></div>
// HTML-INDEX: </div>
>From 8709091091b0ca889ca7911e06b7a4dae61a3581 Mon Sep 17 00:00:00 2001
From: PeterChou1 <peter.chou at mail.utoronto.ca>
Date: Thu, 4 Jul 2024 02:06:08 -0400
Subject: [PATCH 3/5] [clang-doc] fix lines
---
clang-tools-extra/test/clang-doc/enum.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp
index 1e7dd6e4c5b0c..5a1452788a55f 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -34,5 +34,5 @@ enum Color {
// MD-INDEX: | Red |
// MD-INDEX: | Green |
// MD-INDEX: | Blue |
-// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11*
+// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#9*
// MD-INDEX: **brief** For specifying RGB colors
\ No newline at end of file
>From cd98a8cc662527e1488be17a2963874eb3267409 Mon Sep 17 00:00:00 2001
From: PeterChou1 <peter.chou at mail.utoronto.ca>
Date: Fri, 12 Jul 2024 07:03:34 -0400
Subject: [PATCH 4/5] [clang-doc] address pr comments
---
clang-tools-extra/test/clang-doc/enum.cpp | 34 ++++++++++-------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp
index 5a1452788a55f..fcc05477903ff 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -1,31 +1,25 @@
-// RUN: clang-doc --format=html --doxygen --output=%t/docs --executor=standalone %s
-// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone %s
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html -check-prefix=HTML-INDEX
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md -check-prefix=MD-INDEX
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.html -check-prefix=HTML-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-INDEX
/**
* @brief For specifying RGB colors
*/
enum Color {
- Red, // Red enums
- Green, // Green enums
- Blue // Blue enums
+ Red,
+ Green,
+ Blue
};
// HTML-INDEX: <h1>Global Namespace</h1>
// HTML-INDEX: <h2 id="Enums">Enums</h2>
-// HTML-INDEX: <div>
-// HTML-INDEX: <h3 id="{{([0-9A-F]{40})}}">enum Color</h3>
-// HTML-INDEX: <ul>
-// HTML-INDEX: <li>Red</li>
-// HTML-INDEX: <li>Green</li>
-// HTML-INDEX: <li>Blue</li>
-// HTML-INDEX: </ul>
-// HTML-INDEX: <p>Defined at line 9 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
-// HTML-INDEX: <div>
-// HTML-INDEX: <div></div>
-// HTML-INDEX: </div>
-// HTML-INDEX: </div>
+// HTML-INDEX: <h3 id="{{([0-9A-F]{40})}}">enum Color</h3>
+// HTML-INDEX: <li>Red</li>
+// HTML-INDEX: <li>Green</li>
+// HTML-INDEX: <li>Blue</li>
+// HTML-INDEX: <p>Defined at line 10 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
// MD-INDEX: # Global Namespace
// MD-INDEX: ## Enums
@@ -34,5 +28,5 @@ enum Color {
// MD-INDEX: | Red |
// MD-INDEX: | Green |
// MD-INDEX: | Blue |
-// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#9*
+// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#10*
// MD-INDEX: **brief** For specifying RGB colors
\ No newline at end of file
>From f756c39a31135134771a91f279c26a52cac8f0df Mon Sep 17 00:00:00 2001
From: PeterChou1 <peter.chou at mail.utoronto.ca>
Date: Mon, 15 Jul 2024 19:18:36 -0400
Subject: [PATCH 5/5] [clang-doc] fix up enum test cases
---
clang-tools-extra/test/clang-doc/enum.cpp | 130 +++++++++++++++++++---
1 file changed, 113 insertions(+), 17 deletions(-)
diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp
index fcc05477903ff..1e574a9b2b8f4 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -2,24 +2,13 @@
// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
// RUN: FileCheck %s < %t/GlobalNamespace/index.html -check-prefix=HTML-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/Animals.html -check-prefix=HTML-ANIMAL
+// RUN: FileCheck %s < %t/Vehicles/index.html -check-prefix=HTML-VEHICLES
// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/Animals.md -check-prefix=MD-ANIMAL
+// RUN: FileCheck %s < %t/Vehicles/index.md -check-prefix=MD-VEHICLES
-/**
- * @brief For specifying RGB colors
- */
-enum Color {
- Red,
- Green,
- Blue
-};
-// HTML-INDEX: <h1>Global Namespace</h1>
-// HTML-INDEX: <h2 id="Enums">Enums</h2>
-// HTML-INDEX: <h3 id="{{([0-9A-F]{40})}}">enum Color</h3>
-// HTML-INDEX: <li>Red</li>
-// HTML-INDEX: <li>Green</li>
-// HTML-INDEX: <li>Blue</li>
-// HTML-INDEX: <p>Defined at line 10 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
// MD-INDEX: # Global Namespace
// MD-INDEX: ## Enums
@@ -28,5 +17,112 @@ enum Color {
// MD-INDEX: | Red |
// MD-INDEX: | Green |
// MD-INDEX: | Blue |
-// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#10*
-// MD-INDEX: **brief** For specifying RGB colors
\ No newline at end of file
+// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE+13]]*
+// MD-INDEX: **brief** For specifying RGB colors
+
+// HTML-INDEX: <h1>Global Namespace</h1>
+// HTML-INDEX: <h2 id="Enums">Enums</h2>
+// HTML-INDEX: <h3 id="{{([0-9A-F]{40})}}">enum Color</h3>
+// HTML-INDEX: <li>Red</li>
+// HTML-INDEX: <li>Green</li>
+// HTML-INDEX: <li>Blue</li>
+// HTML-INDEX: <p>Defined at line [[@LINE+4]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
+/**
+ * @brief For specifying RGB colors
+ */
+enum Color {
+ Red, ///< Red
+ Green, ///< Green
+ Blue ///< Blue
+};
+
+
+// MD-INDEX: | enum class Shapes |
+// MD-INDEX: --
+// MD-INDEX: | Circle |
+// MD-INDEX: | Rectangle |
+// MD-INDEX: | Triangle |
+// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE+11]]*
+// MD-INDEX: **brief** Shape Types
+
+// HTML-INDEX: <h3 id="{{([0-9A-F]{40})}}">enum class Shapes</h3>
+// HTML-INDEX: <li>Circle</li>
+// HTML-INDEX: <li>Rectangle</li>
+// HTML-INDEX: <li>Triangle</li>
+// HTML-INDEX: <p>Defined at line [[@LINE+4]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
+/**
+ * @brief Shape Types
+ */
+enum class Shapes {
+ /// Circle
+ Circle,
+ /// Rectangle
+ Rectangle,
+ /// Triangle
+ Triangle
+};
+
+
+// MD-ANIMAL: # class Animals
+// MD-ANIMAL: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE+18]]*
+// MD-ANIMAL: ## Enums
+// MD-ANIMAL: | enum AnimalType |
+// MD-ANIMAL: --
+// MD-ANIMAL: | Dog |
+// MD-ANIMAL: | Cat |
+// MD-ANIMAL: | Iguana |
+// MD-ANIMAL: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE+16]]*
+// MD-ANIMAL: **brief** specify what animal the class is
+
+// HTML-ANIMAL: <h1>class Animals</h1>
+// HTML-ANIMAL: <p>Defined at line [[@LINE+7]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
+// HTML-ANIMAL: <h2 id="Enums">Enums</h2>
+// HTML-ANIMAL: <h3 id="{{([0-9A-F]{40})}}">enum AnimalType</h3>
+// HTML-ANIMAL: <li>Dog</li>
+// HTML-ANIMAL: <li>Cat</li>
+// HTML-ANIMAL: <li>Iguana</li>
+// HTML-ANIMAL: <p>Defined at line [[@LINE+6]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
+class Animals {
+public:
+ /**
+ * @brief specify what animal the class is
+ */
+ enum AnimalType {
+ Dog, /// Man's best friend
+ Cat, /// Man's other best friend
+ Iguana /// A lizard
+ };
+};
+
+
+
+// MD-VEHICLES: # namespace Vehicles
+// MD-VEHICLES: ## Enums
+// MD-VEHICLES: | enum Car |
+// MD-VEHICLES: --
+// MD-VEHICLES: | Sedan |
+// MD-VEHICLES: | SUV |
+// MD-VEHICLES: | Pickup |
+// MD-VEHICLES: | Hatchback |
+// MD-VEHICLES: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE+15]]*
+// MD-VEHICLES: **brief** specify type of car
+
+// HTML-VEHICLES: <h1>namespace Vehicles</h1>
+// HTML-VEHICLES: <h2 id="Enums">Enums</h2>
+// HTML-VEHICLES: <h3 id="{{([0-9A-F]{40})}}">enum Car</h3>
+// HTML-VEHICLES: <li>Sedan</li>
+// HTML-VEHICLES: <li>SUV</li>
+// HTML-VEHICLES: <li>Pickup</li>
+// HTML-VEHICLES: <li>Hatchback</li>
+// HTML-VEHICLES: <p>Defined at line [[@LINE+5]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
+namespace Vehicles {
+ /**
+ * @brief specify type of car
+ */
+ enum Car {
+ Sedan, /// Sedan
+ SUV, /// SUV
+ Pickup, /// Pickup
+ Hatchback /// Hatchback
+ };
+}
\ No newline at end of file
More information about the cfe-commits
mailing list