SIGN IN SIGN UP

docs: Enable Ruff formatting of Python code blocks in Markdown (#2099)

### 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.
- `website/versioned_docs/**` and `src/crawlee/project_template` stay
excluded, so frozen doc snapshots and the template are untouched.
- 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 585 files before and after.

*✍️ Drafted by Claude Code*
V
Vlada Dusek committed
f24c551728fbbc393e6c4ffc2cac26fc91143b8b
Parent: 3e9fd11
Committed by GitHub <noreply@github.com> on 7/29/2026, 5:05:12 PM