Run `black` on python code blocks in documentation files
Project description
blacken-docs
Run black
on python code blocks in documentation files.
install
pip install blacken-docs
usage
blacken-docs
provides a single executable (blacken-docs
) which will modify
.rst
/ .md
files in place.
It currently supports the following black
options:
-l
/--line-length
-t
/--target-version
-S
/--skip-string-normalization
Following additional parameters can be used:
-E
/--skip-errors
blacken-docs
will format code in the following block types:
(markdown)
```python
def hello():
print("hello world")
```
(rst)
.. code-block:: python
def hello():
print("hello world")
usage with pre-commit
See pre-commit for instructions
Sample .pre-commit-config.yaml
:
- repo: https://github.com/asottile/blacken-docs
rev: v1.2.0
hooks:
- id: blacken-docs
additional_dependencies: [black==...]
Since black
is currently a moving target, it is suggested to pin black
to a specific version using additional_dependencies
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
blacken_docs-1.2.0.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for blacken_docs-1.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffc16e490c5a6d173786d780a4860756cf244e8f8b518861b0d385cddc2c1d71 |
|
MD5 | b55be277e5d5a111aad0a79a4c86dd5e |
|
BLAKE2b-256 | 214378cc1117d258c4339a231298780d88e0ec81cc6856188fd02d17b81f5ca2 |