docstring-frame
DocsProse drops a multi-line
A docstring carries two readings inside one triple-quoted region. The description prose between the opening """ and the first section heading reads as paragraphs, where 76 characters is the comfortable line for sustained reading. Every Title-case-headed section that follows reads as a code-shaped table, where the line budget matches the surrounding code's code-line-length (88 by default) so that argument annotations sit at the same column as the function body's expressions.
The rule reads docstring-line-length for the description budget, code-line-length for the structured budget, and docstring-structured-policy to override the structured budget when a project prefers a single narrower line across the whole docstring. Code blocks inside the description (fenced or indented) are preserved verbatim, since their layout is load-bearing. The two sibling docstring rules sit upstream of this one:
| Key | Type | Default | Meaning |
|---|---|---|---|
enabled | bool | true | Toggle the rule on or off |
Description and structured budgets come from the top-level Configuration keys: docstring-line-length (default 76), code-line-length (default 88), and docstring-structured-policy (defaulting to "code-line-length") drive the column targets.
Description prose wraps to docstring-line-length, with the existing paragraph structure preserved across the rewrap.
def greet():
"""
The function-level description carries the same wrap shape as the module
docstring, with each wrapped line indented to match the docstring body.
"""
return 1
An Attributes: section in a class Args: entry uses. The walker visits every body whose first statement is a string literal, so class and function docstrings reshape identically.
A Args: section wraps each region to its own shape. The paragraph wraps at the docstring budget against the body indent, and the Args: entry wraps at the same budget with a hanging indent at the description column.
A long Args: entry that overruns its line re-wraps to the section budget with a hanging indent at the description's start column, so continuation lines sit under the description rather than at the parameter-list indent. A short sibling entry below it is left alone.
A Returns: section body wraps to the section budget, so the return-value description tracks the same horizontal room the Args: table uses rather than the narrower description budget.
A .config.toml sidecar flips docstring-structured-policy so non-entry section bodies wrap at the narrower Note: paragraph wraps at the docstring width once the policy selects it.
A Args: and Returns: entries produce no edit.
List items pass through verbatim and are never re-flowed onto multiple lines, even when an item runs long. The recognized markers cover -, *, +, and numeric ordered items, matching the CommonMark set. Body text after the list resumes the description budget.
A triple-backtick fenced code block passes through verbatim no matter how wide its lines run. The fence marks the region as code rather than prose, so the wrap math leaves it untouched.
A four-space-indented block under a description paragraph passes through verbatim because indented blocks read as code samples. Re-flowing them would damage their semantics, so the rule leaves the over-budget lines in place.
Prose drops a multi-line
Prose expands a one-line
For the budget semantics, the Docstring Budgets section of the Configuration chapter covers how the description and structured budgets interact.