Skip to content

feat: use ruff to format docs code instead of blacken-docs#833

Merged
henryiii merged 5 commits into
mainfrom
ruff-016-markdown-docs
Jul 24, 2026
Merged

feat: use ruff to format docs code instead of blacken-docs#833
henryiii merged 5 commits into
mainfrom
ruff-016-markdown-docs

Conversation

@henryiii

@henryiii henryiii commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

I think "markdown" will be added to the hook, in which case this simplifies. See astral-sh/ruff-pre-commit#159.

Close #343.

🤖 AI text below 🤖

Ruff 0.16 can format Python code blocks in Markdown, a stable blacken-docs replacement, so one tool now covers both code and docs.

  • Template & this repo: drop the blacken-docs hook, bump ruff-pre-commit to v0.16.0, and add markdown to the ruff-format hook's types_or (the hook filters files, so Markdown must be listed).
  • PC111 retitled to "Formats code in docs"; it now passes with either blacken-docs or a ruff-format hook that has markdown in types_or. Still flags the old asottile/blacken-docs URL.
  • Guide: recommend the ruff-format approach first, keeping blacken-docs for Black users or reStructuredText (which ruff doesn't format); bumped ruff revs to v0.16.0.
  • Enabling this on our own docs reformatted one code block in docs/principles/design.md (a trailing comma).

Ruff 0.16 also expands the default rule set, but the guide already recommends an explicit select, so that change doesn't affect projects following it.


📚 Documentation preview 📚: https://scientific-python-cookie--833.org.readthedocs.build/

@henryiii
henryiii force-pushed the ruff-016-markdown-docs branch from cc2937c to ebe1a42 Compare July 24, 2026 05:12
henryiii added 2 commits July 24, 2026 01:18
Ruff 0.16 formats Python code blocks in Markdown, so a single tool covers
both code and docs. Drop the blacken-docs hook, bump ruff-pre-commit to
v0.16.0, and add markdown to the ruff-format hook's types_or.

PC111 now passes with either blacken-docs or a ruff-format hook that lists
markdown in types_or.

Assisted-by: ClaudeCode:claude-opus-4.8
Assisted-by: ClaudeCode:claude-opus-4.8
@henryiii
henryiii force-pushed the ruff-016-markdown-docs branch from ebe1a42 to 99b32d8 Compare July 24, 2026 05:18
@henryiii henryiii closed this Jul 24, 2026
@henryiii henryiii reopened this Jul 24, 2026
henryiii added 3 commits July 24, 2026 15:23
Ruff's pre-commit hook will format Markdown by default at some point.
Pass PC111 unless the ruff-format hook filters Markdown out, instead of
requiring a literal `markdown` entry.

Assisted-by: ClaudeCode:claude-opus-5
Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
@henryiii
henryiii merged commit 60770f4 into main Jul 24, 2026
33 checks passed
@henryiii
henryiii deleted the ruff-016-markdown-docs branch July 24, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Ruff's docstring-code-format

1 participant