Files
wehub-resource-sync d0aab9212a
test release tool / test-release-tool (macOS-latest, 3.12) (push) Waiting to run
test release tool / test-release-tool (macOS-latest, 3.13) (push) Waiting to run
test release tool / test-release-tool (macOS-latest, 3.14) (push) Waiting to run
test release tool / test-release-tool (macOS-latest, 3.15) (push) Waiting to run
docker / build (linux/arm64) (push) Waiting to run
docker / push (push) Blocked by required conditions
docs / docs (windows-latest) (push) Waiting to run
test release tool / test-release-tool (windows-latest, 3.12) (push) Waiting to run
test release tool / test-release-tool (windows-latest, 3.13) (push) Waiting to run
test release tool / test-release-tool (windows-latest, 3.14) (push) Waiting to run
test release tool / test-release-tool (windows-latest, 3.15) (push) Waiting to run
test / test (macOS-latest, 3.10) (push) Waiting to run
test / test (macOS-latest, 3.11) (push) Waiting to run
test / test (macOS-latest, 3.12.10) (push) Waiting to run
test / test (macOS-latest, 3.13) (push) Waiting to run
test / test (macOS-latest, 3.14) (push) Waiting to run
test / test (macOS-latest, 3.15) (push) Waiting to run
test / test (macOS-latest, pypy3.11-v7.3.22) (push) Waiting to run
test / test (windows-11-arm, 3.11) (push) Waiting to run
test / test (windows-11-arm, 3.12.10) (push) Waiting to run
test / test (windows-11-arm, 3.13) (push) Waiting to run
test / test (windows-11-arm, 3.14) (push) Waiting to run
test / test (windows-11-arm, 3.15) (push) Waiting to run
test / test (windows-latest, 3.10) (push) Waiting to run
test / test (windows-latest, 3.11) (push) Waiting to run
test / test (windows-latest, 3.12.10) (push) Waiting to run
test / test (windows-latest, 3.13) (push) Waiting to run
test / test (windows-latest, 3.14) (push) Waiting to run
test / test (windows-latest, 3.15) (push) Waiting to run
test / test (windows-latest, pypy3.11-v7.3.22) (push) Waiting to run
test / coveralls-finish (push) Blocked by required conditions
test / uvloop (macOS-latest) (push) Waiting to run
test / uvloop (windows-11-arm) (push) Waiting to run
test / uvloop (windows-latest) (push) Waiting to run
fuzz / fuzz (3.11) (push) Failing after 1s
fuzz / fuzz (3.12) (push) Failing after 1s
build and publish / sdist + pure wheel (push) Failing after 0s
diff-shades / analysis / base / ${{ matrix.mode }} (push) Has been skipped
diff-shades / compare / ${{ matrix.mode }} (push) Waiting to run
docs / docs (ubuntu-latest) (push) Failing after 2s
fuzz / fuzz (3.10) (push) Failing after 1s
fuzz / fuzz (3.14) (push) Failing after 0s
lint and format / lint (push) Failing after 1s
build and publish / publish-mypyc (push) Waiting to run
diff-shades / configure (push) Failing after 1s
docker / build (linux/amd64) (push) Has been skipped
diff-shades / analysis / target / ${{ matrix.mode }} (push) Has been skipped
fuzz / fuzz (3.13) (push) Failing after 0s
fuzz / create-issue (push) Waiting to run
build and publish / generate wheels matrix (push) Failing after 0s
test release tool / test-release-tool (ubuntu-latest, 3.13) (push) Failing after 1s
build and publish / mypyc wheels ${{ matrix.only }} (push) Has been skipped
build and publish / publish-hatch (push) Waiting to run
test / test (ubuntu-latest, 3.10) (push) Failing after 0s
test / test (ubuntu-latest, 3.11) (push) Failing after 1s
test / test (ubuntu-latest, 3.13) (push) Failing after 0s
test / test (ubuntu-latest, pypy3.11-v7.3.22) (push) Failing after 1s
test / test (ubuntu-latest, 3.15) (push) Failing after 1s
test release tool / test-release-tool (ubuntu-latest, 3.15) (push) Failing after 0s
zizmor / zizmor (push) Failing after 0s
test release tool / test-release-tool (ubuntu-latest, 3.12) (push) Failing after 4s
test release tool / test-release-tool (ubuntu-latest, 3.14) (push) Failing after 3s
test / uvloop (ubuntu-latest) (push) Failing after 1s
test / test (ubuntu-latest, 3.14) (push) Failing after 1s
test / test (ubuntu-latest, 3.12.10) (push) Failing after 5s
chore: import upstream snapshot with attribution
2026-07-13 12:07:39 +08:00

2.5 KiB

Doctest Formatting

While Black makes some decisions about styling for docstrings, it does not make any assumptions about the contents of documentation. Thus, executable Python code inside docstrings or documentation files (e.g. doctests), will not be formatted by Black.

Listed below are tools that apply Black formatting to code inside docstrings and documentation files.

Note: There are some observed inconsistencies between the below packages. Because of this, we hesitate to make any recommendations. Any installed packages are installed at your own risk. We also encourage anyone to contribute documentation for additional packages that apply Black formatting to doctests.

blacken-docs

blacken-docs is primarily used to apply Black formatting to code in documentation files (e.g. .rst, .md, .tex).

blacken-docs supports the following:

  • Python code blocks in Markdown, reStructuredText, and LaTeX files. Similar to blackdoc, normal Black formatting is applied, so doctests inside Python code blocks will not be formatted.

    ```python
    print("Hello world!")
    ```
    
    .. code-block:: python
        print("Hello world!")
    
    \begin{minted}{python}
    print("Hello world!")
    \end{minted}
    
  • Doctests inside Pycon code blocks in Markdown and reStructuredText. The code blocks may be included in a .md or .rst file, or inside a docstring in a Python file.

    ```python
    >>> print("Hello world!")
    ```
    
    .. code-block:: pycon
        >>> print("Hello world!")
    
    def add_one(n: int) -> int:
        """
        Examples
        --------
        ```pycon
        >>> add_one(1) == 2
        ```
        """
        return n + 1
    

blackdoc

blackdoc is primarily used to apply Black formatting to doctests in Python files. It will not format any file contents that are otherwise covered by Black.

blackdoc supports the following:

  • Doctests in Python files.

    def add_one(n: int) -> int:
        """
        Examples
        --------
        >>> add_one(1) == 2
        """
        return n + 1
    
  • Python code blocks in Markdown or reStructuredText files. In these cases, normal Black formatting is applied, i.e., doctests inside Python code blocks will not be formatted.

    ```python
    print("Hello world!")
    ```
    
    .. code-block:: python
        print("Hello world!")