Skip to main content
https://github.com/keewis/blackdoc/actions/workflows/ci.yml/badge.svg?branch=main https://img.shields.io/badge/code%20style-black-000000.svg Documentation Status

blackdoc is a tool that applies black to code in documentation.

It was originally a rewrite of a gist and called black-doctest. In April 2020, it was renamed to blackdoc.

Installation

Dependencies:

Install it with:

python -m pip install blackdoc

Usage

The commandline interface supports two modes: checking and inplace reformatting.

python -m blackdoc --help

In inplace reformatting mode, it will reformat the doctest lines and write them back to disk:

# on explicitly mentioned files
python -m blackdoc file1.py file2.py
# on the whole directory
python -m blackdoc .

When checking, it will report the changed files but will not write them to disk:

python -m blackdoc --check .

It is also possible to use the entrypoint script:

blackdoc --help

pre-commit

This repository defines a pre-commit hook:

hooks:
...
- repo: https://github.com/keewis/blackdoc
  rev: 3.8.0
  hooks:
  - id: blackdoc

It is recommended to pin black in order to avoid having different versions for each contributor. To automatically synchronize this pin with the version of the black hook, use the blackdoc-autoupdate-black hook:

hooks:
...
- repo: https://github.com/psf/black
  rev: 23.10.1
  hooks:
  - id: black
...
- repo: https://github.com/keewis/blackdoc
  rev: 3.8.0
  hooks:
  - id: blackdoc
    additional_dependencies: ["black==23.10.1"]
  - id: blackdoc-autoupdate-black

Note that this hook is not run on pre-commit autoupdate.

Release files for blackdoc 0.4.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for blackdoc 0.4.6
File Size Uploaded
blackdoc-0.4.6.tar.gz 42.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for blackdoc 0.4.6
File Interpreter ABI Platform
blackdoc-0.4.6-py3-none-any.whl Python 3 none any Details

Total release size: 82.8 kB

Release files / blackdoc-0.4.6.tar.gz

Download URL blackdoc-0.4.6.tar.gz
Size 42.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9cce04cd898ed0ceb1c423836e62024e1d118a38ee5f760b931cadf7761b964f
BLAKE2b-256 checksum
How to use checksums
313b2ae2120a479975c34022d49e0139a472cda17488043e5e9496e0e1786164
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2025.

Transparency log

Release files / blackdoc-0.4.6-py3-none-any.whl

Download URL blackdoc-0.4.6-py3-none-any.whl
Size 40.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85d78ae44d07e8d85a318276813abfa8b8bcf236b47983aa203f692e139533ab
BLAKE2b-256 checksum
How to use checksums
675bfe2e48b50f963e4381b03de0652cdfa9b912af207bcf6f3e04e248629896
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.6 This release

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3

2 release files

0.2

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page