ruff-pre-commit icon indicating copy to clipboard operation
ruff-pre-commit copied to clipboard

add ruff-docs

Open inktrap opened this issue 1 year ago • 2 comments

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 avatar May 25 '24 21:05 inktrap

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.

inktrap avatar May 25 '24 23:05 inktrap

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?

charliermarsh avatar May 27 '24 00:05 charliermarsh

ok

CAPTAINJAYKIRK avatar Apr 08 '25 14:04 CAPTAINJAYKIRK