diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index e604d4b..91937e3 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -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]"] diff --git a/README.rst b/README.rst index 00247ed..f5e88c1 100644 --- a/README.rst +++ b/README.rst @@ -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