Commit ac0e4dd
authored
Add MLIR code block highlighting to python bindings docs (#245)
As mentioned in
#239 (comment),
currently many MLIR code blocks in the Python bindings’ Sphinx
documentation are missing syntax highlighting.
Sphinx uses the [Pygments](https://github.com/pygments/pygments) library
for lexical analysis and syntax highlighting, but Pygments doesn’t
include a built-in lexer for MLIR.
In this PR, we leverage
https://github.com/llvm/llvm-project/blob/main/mlir/utils/pygments/mlir_lexer.py
(interestingly, the LLVM repository already contains a Pygments lexer
for MLIR) and integrate it into the Sphinx setup.
Before:
<img width="1496" height="685" alt="image"
src="https://github.com/user-attachments/assets/90ef57ca-9a59-4039-9e42-34a04eda494d"
/>
After:
<img width="1482" height="658" alt="image"
src="https://github.com/user-attachments/assets/a7b0c52e-3735-480f-9321-59268517bca4"
/>
You can preview this change at https://mlir-python-hl.surge.sh/.
cc @jpienaar @makslevental1 parent ded2375 commit ac0e4dd
File tree
3 files changed
+24
-1
lines changed- .github/workflows
- sphinx-mlir-python
- _static
3 files changed
+24
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
53 | 69 | | |
54 | 70 | | |
55 | 71 | | |
| |||
0 commit comments