[Mlir-commits] [mlir] 9a8ff34 - [mlir][doc] Trim summary text during DocGen (#68477)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Oct 13 01:09:50 PDT 2023


Author: Rik Huijzer
Date: 2023-10-13T10:09:44+02:00
New Revision: 9a8ff346bb20a684e8edd62035077aba06bea084

URL: https://github.com/llvm/llvm-project/commit/9a8ff346bb20a684e8edd62035077aba06bea084
DIFF: https://github.com/llvm/llvm-project/commit/9a8ff346bb20a684e8edd62035077aba06bea084.diff

LOG: [mlir][doc] Trim summary text during DocGen (#68477)

When defining a multi-line string in tblgen, the output in the Markdown
file currently contains too much whitespace and newlines for Hugo's
Markdown parser. For example, for `arith.addui_extended` the tblgen
```tblgen
let summary = [{
  extended unsigned integer addition operation returning sum and overflow bit
}];
```
is currently converted to
```markdown
_
    extended unsigned integer addition operation returning sum and overflow bit
  _
```
which causes the text to not be italicized (as can be seen at
https://mlir.llvm.org/docs/Dialects/ArithOps/#arithaddui_extended-arithadduiextendedop).
After this PR, the output becomes
```
_Extended unsigned integer addition operation returning sum and overflow bit_
```

Added: 
    

Modified: 
    mlir/tools/mlir-tblgen/OpDocGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp
index 855f02d828418dd..773ad6ec198b957 100644
--- a/mlir/tools/mlir-tblgen/OpDocGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp
@@ -54,8 +54,9 @@ using mlir::tblgen::Operator;
 
 void mlir::tblgen::emitSummary(StringRef summary, raw_ostream &os) {
   if (!summary.empty()) {
-    char first = std::toupper(summary.front());
-    llvm::StringRef rest = summary.drop_front();
+    llvm::StringRef trimmed = summary.trim();
+    char first = std::toupper(trimmed.front());
+    llvm::StringRef rest = trimmed.drop_front();
     os << "\n_" << first << rest << "_\n\n";
   }
 }


        


More information about the Mlir-commits mailing list