diff options
author | Rik Huijzer <github@huijzer.xyz> | 2023-12-23 21:48:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-23 21:48:33 +0100 |
commit | 061e4f24b24a3b59d73a94dc6f2f0d21a2b7beac (patch) | |
tree | d41f0fb745ffee12db0b8606f7bae763b14b6e06 | |
parent | acacec3bbf4586ef9bc6c4f31707d3515d5215a1 (diff) | |
download | llvm-061e4f24b24a3b59d73a94dc6f2f0d21a2b7beac.zip llvm-061e4f24b24a3b59d73a94dc6f2f0d21a2b7beac.tar.gz llvm-061e4f24b24a3b59d73a94dc6f2f0d21a2b7beac.tar.bz2 |
[mlir][doc] Escape effects, interfaces, and traits (#76297)
Fixes https://github.com/llvm/llvm-project/issues/76270.
Thanks to @scottamain for the clear description.
Co-authored-by: Scott Main <scott@modular.com>
-rw-r--r-- | mlir/test/mlir-tblgen/gen-dialect-doc.td | 6 | ||||
-rw-r--r-- | mlir/tools/mlir-tblgen/OpDocGen.cpp | 12 |
2 files changed, 12 insertions, 6 deletions
diff --git a/mlir/test/mlir-tblgen/gen-dialect-doc.td b/mlir/test/mlir-tblgen/gen-dialect-doc.td index ca0b6e3..c9492eb 100644 --- a/mlir/test/mlir-tblgen/gen-dialect-doc.td +++ b/mlir/test/mlir-tblgen/gen-dialect-doc.td @@ -81,9 +81,9 @@ def TestTypeDefParams : TypeDef<Test_Dialect, "TestTypeDefParams"> { // CHECK: Other group // CHECK: test.b // CHECK: test.c -// CHECK: Traits: SingleBlock, SingleBlockImplicitTerminator<YieldOp> -// CHECK: Interfaces: NoMemoryEffect (MemoryEffectOpInterface) -// CHECK: Effects: MemoryEffects::Effect{} +// CHECK: Traits: `SingleBlockImplicitTerminator<YieldOp>`, `SingleBlock` +// CHECK: Interfaces: `NoMemoryEffect (MemoryEffectOpInterface)` +// CHECK: Effects: `MemoryEffects::Effect{}` // CHECK: ## Attribute constraints // CHECK: ### attribute summary diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp index 877ef10..7cd2690 100644 --- a/mlir/tools/mlir-tblgen/OpDocGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp @@ -123,6 +123,12 @@ static void emitAssemblyFormat(StringRef opName, StringRef format, os << "```\n\n"; } +/// Place `text` between backticks so that the Markdown processor renders it as +/// inline code. +static std::string backticks(const std::string &text) { + return '`' + text + '`'; +} + static void emitOpTraitsDoc(const Operator &op, raw_ostream &os) { // TODO: We should link to the trait/documentation of it. That also means we // should add descriptions to traits that can be queried. @@ -155,14 +161,14 @@ static void emitOpTraitsDoc(const Operator &op, raw_ostream &os) { os << effect << " on " << rec->getValueAsString("resource"); }); os << "}"; - effects.insert(os.str()); + effects.insert(backticks(os.str())); name.append(llvm::formatv(" ({0})", traitName).str()); } - interfaces.insert(name); + interfaces.insert(backticks(name)); continue; } - traits.insert(name); + traits.insert(backticks(name)); } if (!traits.empty()) { llvm::interleaveComma(traits, os << "\nTraits: "); |