Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@
description: Run `black` on python code blocks in documentation files
entry: blacken-docs
language: python
files: '\.(rst|md|markdown|py|tex)$'
types_or: [rst, markdown, tex, python, pyi]
- id: blacken-docs-jupyter
name: blacken-docs-jupyter
description: Run `black` on python code blocks in documentation files (with Jupyter Notebook support)
entry: blacken-docs
language: python
types_or: [rst, markdown, tex, python, pyi, jupyter]
additional_dependencies: ["black[jupyter]"]
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ Add the following to the ``repos`` section of your ``.pre-commit-config.yaml`` f
additional_dependencies:
- black==22.12.0

Or with Jupyter notebook support
(note the latest ``black[jupyter]`` is built-into this hook):

.. code-block:: yaml

- repo: https://github.com/adamchainz/blacken-docs
rev: "" # replace with latest tag on GitHub
hooks:
- id: blacken-docs-jupyter

Then, reformat your entire project:

.. code-block:: sh
Expand Down