[Mlir-commits] [mlir] Add support for enum doc gen (PR #98885)

Jacques Pienaar llvmlistbot at llvm.org
Mon Jul 15 11:44:31 PDT 2024


================
@@ -381,6 +381,39 @@ static void emitAttrOrTypeDefDoc(const RecordKeeper &recordKeeper,
     emitAttrOrTypeDefDoc(AttrOrTypeDef(def), os);
 }
 
+//===----------------------------------------------------------------------===//
+// Enum Documentation
+//===----------------------------------------------------------------------===//
+
+static void emitEnumDoc(const EnumAttr &def, raw_ostream &os) {
+  os << llvm::formatv("### {0}\n", def.getEnumClassName());
+
+  // Emit the summary if present.
+  if (!def.getSummary().empty())
+    os << "\n" << def.getSummary() << "\n";
+
+  // Emit case documentation.
+  std::vector<EnumAttrCase> cases = def.getAllCases();
+  os << "\n#### Cases:\n\n";
----------------
jpienaar wrote:

Oh exactly, that was part of my question: if something would have flagged this as error already so that we don't even have to worry about the empty case. I think this is fine. doc generator can be a bit conservative :)

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


More information about the Mlir-commits mailing list