[clang-tools-extra] [Clang-doc] Display values and comments in MD (PR #183754)

Samrudh Nelli via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 7 03:55:07 PST 2026


================
@@ -163,13 +206,37 @@ static void genMarkdown(const ClangDocContext &CDCtx, const EnumInfo &I,
   if (I.BaseType && !I.BaseType->Type.QualName.empty()) {
     OS << ": " << I.BaseType->Type.QualName << " ";
   }
-  OS << "|\n\n" << "--\n\n";
+  OS << "|\n\n";
 
   std::string Buffer;
   llvm::raw_string_ostream Members(Buffer);
-  if (!I.Members.empty())
-    for (const auto &N : I.Members)
-      Members << "| " << N.Name << " |\n";
+  Members << "| Name | Value |";
+  if (!I.Members.empty()) {
+    bool HasComments = false;
+    for (const auto &Member : I.Members) {
+      if (!Member.Description.empty()) {
+        HasComments = true;
+        Members << " Comments |";
+        break;
+      }
+    }
+    Members << "\n";
+    Members << "|:-:|:-:|";
+    if (HasComments)
+      Members << ":-:|";
+    Members << "\n";
+    for (const auto &N : I.Members) {
+      Members << "| " << N.Name << " ";
+      if (!N.Value.empty())
+        Members << "| " << N.Value << " ";
----------------
SamrudhNelli wrote:

In above line 214, we currently add the comments column only if atleast one of the enum member has a comment. Hence, it won't break the table.
Can be subject to changes. If you insist we can omit the check in 214 and print the column in every case.

https://github.com/llvm/llvm-project/pull/183754


More information about the cfe-commits mailing list