Skip to content

Ruff Format Docs#3

Open
calumy wants to merge 27 commits intoadd-pre-commit-cifrom
ruff-format-docs
Open

Ruff Format Docs#3
calumy wants to merge 27 commits intoadd-pre-commit-cifrom
ruff-format-docs

Conversation

@calumy
Copy link
Owner

@calumy calumy commented Dec 30, 2024

Summary

This PR introduces a new hook to run the ruff formatted over code blocks in documentation files. This was built on top of the Blacken-docs project but extended for the ruff formatter. I think this hook should be included in this repo rather than Blacken-docs, as it allows the hook to be versioned with the correct version of ruff and automatically updated when a new version of ruff is added rather than relying on manual updates of the ruff version (as is currently implemented with black in blacken-docs).

Test Plan

  • Test cases ported from blacken-docs
  • Try with try-repo in another repo that has code blocks in documentation e.g. the main ruff repo. uv run pre-commit try-repo <path-to-pre-commit-ruff> ruff-format-docs --files crates/**/resources/mdtest/*.md
    • Main changes introduced here are the addition of extra white blank lines before function definitions
    • Note some files fail to parse, but these are due to invalid syntax in the files. These files are excluded by the current blacken-docs config in this repo.

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.

1 participant