Skip to content

Commit 061e4f2

Browse files
[mlir][doc] Escape effects, interfaces, and traits (#76297)
Fixes #76270. Thanks to @scottamain for the clear description. Co-authored-by: Scott Main <[email protected]>
1 parent acacec3 commit 061e4f2

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

mlir/test/mlir-tblgen/gen-dialect-doc.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ def TestTypeDefParams : TypeDef<Test_Dialect, "TestTypeDefParams"> {
8181
// CHECK: Other group
8282
// CHECK: test.b
8383
// CHECK: test.c
84-
// CHECK: Traits: SingleBlock, SingleBlockImplicitTerminator<YieldOp>
85-
// CHECK: Interfaces: NoMemoryEffect (MemoryEffectOpInterface)
86-
// CHECK: Effects: MemoryEffects::Effect{}
84+
// CHECK: Traits: `SingleBlockImplicitTerminator<YieldOp>`, `SingleBlock`
85+
// CHECK: Interfaces: `NoMemoryEffect (MemoryEffectOpInterface)`
86+
// CHECK: Effects: `MemoryEffects::Effect{}`
8787

8888
// CHECK: ## Attribute constraints
8989
// CHECK: ### attribute summary

mlir/tools/mlir-tblgen/OpDocGen.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ static void emitAssemblyFormat(StringRef opName, StringRef format,
123123
os << "```\n\n";
124124
}
125125

126+
/// Place `text` between backticks so that the Markdown processor renders it as
127+
/// inline code.
128+
static std::string backticks(const std::string &text) {
129+
return '`' + text + '`';
130+
}
131+
126132
static void emitOpTraitsDoc(const Operator &op, raw_ostream &os) {
127133
// TODO: We should link to the trait/documentation of it. That also means we
128134
// should add descriptions to traits that can be queried.
@@ -155,14 +161,14 @@ static void emitOpTraitsDoc(const Operator &op, raw_ostream &os) {
155161
os << effect << " on " << rec->getValueAsString("resource");
156162
});
157163
os << "}";
158-
effects.insert(os.str());
164+
effects.insert(backticks(os.str()));
159165
name.append(llvm::formatv(" ({0})", traitName).str());
160166
}
161-
interfaces.insert(name);
167+
interfaces.insert(backticks(name));
162168
continue;
163169
}
164170

165-
traits.insert(name);
171+
traits.insert(backticks(name));
166172
}
167173
if (!traits.empty()) {
168174
llvm::interleaveComma(traits, os << "\nTraits: ");

0 commit comments

Comments
 (0)