[Mlir-commits] [mlir] [mlir][doc] Emit `\n` if description not end with `\n`. (PR #112898)

Longsheng Mou llvmlistbot at llvm.org
Fri Oct 18 05:53:51 PDT 2024


https://github.com/CoTinker created https://github.com/llvm/llvm-project/pull/112898

This PR addresses a markdown formatting issue by ensuring a `\n` is emitted if the description string does not already end with one. Fixes #112672.

>From 56e54748ebda88f31d6b4f1cd45e7014a4d67823 Mon Sep 17 00:00:00 2001
From: Longsheng Mou <longshengmou at gmail.com>
Date: Fri, 18 Oct 2024 20:41:18 +0800
Subject: [PATCH] [mlir][doc] Emit `\n` if description not end with `\n`.

This PR addresses a markdown formatting issue by ensuring a `\n` is
emitted if the description string does not already end with one.
---
 mlir/tools/mlir-tblgen/OpDocGen.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp
index ff3c6b16bb6ebc..d499c78a5cf44d 100644
--- a/mlir/tools/mlir-tblgen/OpDocGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp
@@ -70,7 +70,10 @@ void mlir::tblgen::emitSummary(StringRef summary, raw_ostream &os) {
 // nested in the op definition.
 void mlir::tblgen::emitDescription(StringRef description, raw_ostream &os) {
   raw_indented_ostream ros(os);
-  ros.printReindented(description.rtrim(" \t"));
+  StringRef trimmed = description.rtrim(" \t");
+  ros.printReindented(trimmed);
+  if (!trimmed.ends_with("\n"))
+    ros << "\n";
 }
 
 void mlir::tblgen::emitDescriptionComment(StringRef description,



More information about the Mlir-commits mailing list