Commit 7e24298
authored
Fix render issue of markdown for python bindings sphinx docs (#239)
Sphinx renders docstrings as reStructuredText, but in our MLIR Python
bindings, many op documentations are generated from TableGen and written
in Markdown. As a result, elements like code blocks are broken in the
rendered output, making the docs hard to read.
In this PR, we hook into Sphinx AutoAPI’s docstring processing function
(since Sphinx AutoAPI doesn’t provide an official way to override it)
and use a CommonMark parser to parse the docstrings and re-emit them as
reStructuredText. This allows Sphinx to render the documentation
correctly.
### Before:
https://mlir.llvm.org/python-bindings/autoapi/mlir/dialects/_affine_ops_gen/index.html#mlir.dialects._affine_ops_gen.AffineApplyOp
<img width="1576" height="1094" alt="image"
src="https://github.com/user-attachments/assets/bbfc299b-9efb-46b6-863e-ac21903e0ed6"
/>
### After:
https://mlir-python.surge.sh/autoapi/mlir/dialects/_affine_ops_gen/index.html#mlir.dialects._affine_ops_gen.AffineApplyOp
<img width="1545" height="1199" alt="image"
src="https://github.com/user-attachments/assets/224f5d9b-0677-4169-a32a-eea2edf2fb23"
/>
### Demo
You can preview the website after this change at:
https://mlir-python.surge.sh/
cc @jpienaar @makslevental1 parent c59604f commit 7e24298
2 files changed
+19
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
40 | 55 | | |
41 | 56 | | |
42 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments