Commit 5a48589
authored
docs: Enable Ruff formatting of Python code blocks in Markdown (#982)
### What & why
Ruff 0.16 formats Python code blocks embedded in Markdown files, and
does so by default. In this repo the feature was inert because
`[tool.ruff] include` was an allowlist of `*.py` globs, so no Markdown
file ever reached the formatter. Adding `**/*.md` and `**/*.mdx` turns
it on, which means docs snippets are now held to the same formatting
standard as the rest of the codebase instead of drifting by hand.
MDX needs the explicit `extension = { mdx = "markdown" }` mapping -
without it Ruff would try to parse `.mdx` as Python and fail. Most of
the Python snippets in `docs/` live in `.mdx`, so the mapping is what
makes this useful here.
No changes to the `lint` / `format` Poe tasks are needed. `lint` already
runs `ruff format --check` and `format` already runs `ruff format`, so
both pick Markdown up automatically. Note that `ruff check` (lint rules)
does not support Markdown yet, so only formatting is enforced there.
### Notes
- Code blocks under `docs/` are formatted to 90 columns, not 120,
because of the existing `docs/pyproject.toml` override that keeps doc
snippets free of a horizontal scrollbar. That is why one line in the
upgrading guide got wrapped.
- The second commit collapses the `include` allowlist to a single
`**/*.py` glob. This is a pure simplification: no tracked `.py` file
lives outside the previously listed directories, and Ruff processes
exactly the same 189 files before and after.
*✍️ Drafted by Claude Code*1 parent 784006e commit 5a48589
2 files changed
Lines changed: 11 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
100 | | - | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | | - | |
| 105 | + | |
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
| 85 | + | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
0 commit comments