<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/112672>112672</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir][doc] Adds a `\n` if description string not end with `\n`.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          CoTinker
      </td>
    </tr>
</table>

<pre>
    The `mlir-linalg-ods-yaml-gen` tool converts description to a single-line string in tblgen file.
For example:
```yaml
metadata: !LinalgOpMetadata
  name: abs
  cpp_class_name: AbsOp
  doc: |-
    Applies abs(x) elementwise.

    No numeric casting is performed on the input operand.
```
is converted to
```tblgen
let description = [{No numeric casting is performed on the input operand.}];
```
In this case, the string of description is `"No numeric casting is performed on the input operand."`, without a trailing newline(`\n`). This causes the  `Traits` section to appear on the same line as the end of description in the generated markdown, as seen here  https://mlir.llvm.org/docs/Dialects/Linalg/#linalgabs-linalgabsop.
![image](https://github.com/user-attachments/assets/db1d17af-c770-4d43-b6d9-49f3dc226659)

Generially, we define `description` as a multi-line string in tblgen. Such as:
```tblgen
let description = [{
  No numeric casting is performed on the input operand.
}];
```
In this case, the string becomes `"\n  No numeric casting is performed on the input operand.\n"`, end with `\n`, which ensures that `Traits` starts on a new line after the description.

To fix this, we should append a newline (`\n`) if the description string doesn’t already end with one.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVU2PpDYQ_TXuS4kWGGi6Dxx6utNRpCR7yNxXhV2As8ZGttnZ-feRzTBfO4qiiTTS0EVV-dWr9zB6rwZD1LL6jtXXHS5htK692HtlvpHbdVY-tvcjATvkk1Yu08qgHjIrffaIk84GMuyQQ7BWg7DmO7ngQZIXTs1BWQPBAoJXZtAUiwl8cMoMoAyETg9koFea9iy_svx8sw7oB06zJlae1xg75OtfPG8NTRRQYkBWnoHx4veE6cv8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