[clang-tools-extra] [clang-doc] add enum test (PR #97679)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 15 07:57:57 PDT 2024
================
@@ -0,0 +1,121 @@
+// 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/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, // Red
+ Green, // Green
+ Blue // Blue
+};
+
+/**
+ * @brief Shape Types
+ */
+enum Shapes {
+ // Circle
+ Circle,
+ // Rectangle
+ Rectangle,
+ // Triangle
+ Triangle
+};
+
+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
+ };
+};
+
+
+namespace Vehicles {
+ /**
+ * @brief specify type of car
+ */
+ enum Car {
+ Sedan, // Sedan
+ SUV, // SUV
+ Pickup, // Pickup
+ Hatchback // Hatchback
+ };
+}
+
+
+// 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 {{.*}} of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
----------------
ilovepi wrote:
```suggestion
// HTML-INDEX: <p>Defined at line [[#]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
```
i think this may be what you want to just match a number. It’s also possible to use the LINE directive here, but that may be a bit harder to manage/keep in sync. Probably, just matching the number here is enough, and another prefix can check the line.
https://github.com/llvm/llvm-project/pull/97679
More information about the cfe-commits
mailing list