Skip to content

Conversation

rikhuijzer
Copy link
Member

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

let summary = [{
  extended unsigned integer addition operation returning sum and overflow bit
}];

is currently converted to

_
    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_

@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Oct 7, 2023
@llvmbot
Copy link
Member

llvmbot commented Oct 7, 2023

@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir

Changes

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

let summary = [{
  extended unsigned integer addition operation returning sum and overflow bit
}];

is currently converted to

_
    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_

Full diff: https://github.com/llvm/llvm-project/pull/68477.diff

1 Files Affected:

  • (modified) mlir/tools/mlir-tblgen/OpDocGen.cpp (+3-2)
diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp
index 088d34597f315fc..498aa40435fb115 100644
--- a/mlir/tools/mlir-tblgen/OpDocGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp
@@ -50,8 +50,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";
   }
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants