[Mlir-commits] [mlir] [mlir][docgen] Add ops source link (PR #73657)

Rik Huijzer llvmlistbot at llvm.org
Wed Nov 29 03:57:50 PST 2023


================
@@ -265,10 +265,24 @@ static void emitOpDoc(const Operator &op, raw_ostream &os) {
   os << "\n";
 }
 
+static void emitSourceLink(StringRef inputFilename, raw_ostream &os) {
+  size_t pathBegin = inputFilename.find("mlir/include/mlir/");
+  if (pathBegin == StringRef::npos)
+    return;
+
+  StringRef inputFromMlirInclude = inputFilename.substr(pathBegin);
+
+  os << "<span class=\"op-definitions-source-link\">\n";
+  os << "  <a href=\"https://github.com/llvm/llvm-project/blob/main/"
+     << inputFromMlirInclude << "\">source</a>\n";
+  os << "</span>\n\n";
----------------
rikhuijzer wrote:

I just see that `OpDocGen.cpp` generates more plain HTML by the way, the attributes are generated as a HTML `<table>`:

https://github.com/llvm/llvm-project/blob/47df664c7acfd8abd082c0252d1793182c92dc3d/mlir/tools/mlir-tblgen/OpDocGen.cpp#L211-L235

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


More information about the Mlir-commits mailing list