Skip to main content

Run `black` on python code blocks in documentation files

Project description

Build Status Coverage Status

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: v0.4.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


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-0.5.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blacken_docs-0.5.0-py2.py3-none-any.whl (4.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file blacken_docs-0.5.0.tar.gz.

File metadata

  • Download URL: blacken_docs-0.5.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for blacken_docs-0.5.0.tar.gz
Algorithm Hash digest
SHA256 7b7b1b895287acbcb86451af9391f92327b3ecb7d513783cf99e8990dd0b4938
MD5 5de2713b792854ce2e38e5cbd51107b9
BLAKE2b-256 14ccbb0fef3d13fd2873db1989af82c5a94daf88da5a140eae3a07e0d0595df6

See more details on using hashes here.

File details

Details for the file blacken_docs-0.5.0-py2.py3-none-any.whl.

File metadata

  • Download URL: blacken_docs-0.5.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for blacken_docs-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 483ac178bb706fb77c4a383cd3b5f5eaf0d88f46b57baeaa9a05bf3f79d4d2c3
MD5 08653cb9af2c8a596d99868bee828720
BLAKE2b-256 f65b35049ea1f8e9e68a2b42a5e083b0faf21be80fcab684c2bcf476bba05ed3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page