Skip to content
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 ruff-docs #88

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add ruff-docs #88

wants to merge 1 commit into from

Conversation

inktrap
Copy link

@inktrap inktrap commented May 25, 2024

Summary

Since ruff can fix docs(trings) it can replace something like blacken-docs too, that way everything is consistent.

Test Plan

I forked the repo, added the new hook-id, recreated the current release-tag and used it in a dedicated repo in a pre-commit file and it worked.

@inktrap
Copy link
Author

inktrap commented May 25, 2024

I realized that you can achieve the same thing in one run with the default format action:

    - repo: https://github.com/astral-sh/ruff-pre-commit
      rev: v0.4.5
      hooks:
          - id: ruff
            types_or: [python, pyi, jupyter]
            args: [--fix, --exit-non-zero-on-fix]
          - id: ruff-format
            args: [--config, format.docstring-code-format=true, --config, format.docstring-code-line-length=72]
            types_or: [python, pyi, jupyter, markdown, rst]

However in that case I think it is useful to include it as an example to highlight that possibility.

Especially because it is not immediately clear that you can format docs with the docstring option, but it is a good name (i read the discussion about variable naming). And it is all documented anyways.

@charliermarsh
Copy link
Member

I don't believe docstring formatting currently works on Markdown and rST files though. It supports Markdown and rST within Python docstrings, but not Python code within Markdown or rST files. Am I mistaken?

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.

2 participants