-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new ruff-format-docs
hook
#112
Open
calumy
wants to merge
35
commits into
astral-sh:main
Choose a base branch
from
calumy:ruff-format-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: #111 has been split out of this PR to allow for an independent review of the changes. I am unable to point the base branch to the branch of that PR, as this causes the PR to be created in the forked repo. I hope that #111 can be reviewed and merged first, and then this PR is rebased on top of the changes; however, I have opened this PR to show the utility of some of the hooks added in that PR, e.g. mypy or some of the more opinionated ruff rules.
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).
Naming
Initially, I had thought of this hook as
ruffen-docs
; however, I believeruff-format-docs
aligns better with the other hooks in this repo and also leaves open the door for aruff-check-docs
hook in the future.Licencing
The Blacken-docs repo is licenced under an MIT Licence, so I believe that using it as a starting point is covered by this. I have also included a reference to the Blacken-docs repo in the readme.
Test Plan
uv run pre-commit try-repo <path-to-pre-commit-ruff> ruff-format-docs --files crates/**/resources/mdtest/*.md