docwrap
Docwrap applies configurable formatting rules to Python docstrings. It makes wrapping and layout deterministic, with controls for line length, paragraph reflow, and summary placement. It supports Google, NumPy, and Sphinx/reST conventions.
Run docwrap to see which docstrings would change across your project:
Then use docwrap --preview to compare the original and proposed formatting. For example, using
the default 79-column limit:
Installation
Docwrap requires CPython 3.13 or later. From a checkout, install the command with uv:
uv tool install .
To update an existing installation after pulling changes:
uv tool install --reinstall .
Git is needed for agent hooks and incremental mode; uv is needed for these installation commands, not at runtime.
Quick start
Start with a summary, preview individual docstrings, inspect the diff, then apply the changes:
docwrap
docwrap --preview
docwrap --diff
docwrap --write
Paths default to the current directory. Pass a file or directory to limit the scope.
Use docwrap --stats to inspect line-length distributions, compare wrapping targets, and see
recommendations.
Without --write, docwrap leaves files alone. It exits 0 when no changes are pending or a write
succeeds, 1 when changes are pending, and 2 on an error. Start with the defaults: 79 columns,
smart filling, cautious reflow, and no summary wrapping. To change the width for a project, add:
[tool.docwrap]
line-length = 88
Configuration is discovered from each file's pyproject.toml. The
wrapping policy guide explains the tradeoffs between
reflowing prose and preserving authored layout. See the CLI reference for output
modes, configuration precedence, and advanced options.
Integrations and library use
A local pre-commit hook can run docwrap when you commit. See the pre-commit setup for a writing hook and its report-only variant. Agent hooks for Claude Code, Codex, and Antigravity can run before commits or after edits. Their installation, host settings, commit behavior, and composition limits are in the agent hook guide.
For Python callers, wrap_source() returns rewritten source, check() reports whether it would
change, and wrap_source_report() supplies structured results:
import docwrap
source = 'def greet():\n """Return a greeting."""\n'
result = docwrap.check(source)
wrapped = docwrap.wrap_source(source)
See the library reference for file operations, configuration, result types, and safety skips.
Documentation
- CLI reference: commands, output, configuration, and exit codes.
- Agent hook guide: setup, commit handling, and host responses.
- Incremental mode: wrap only changed files or definitions.
- Library reference: supported Python API and result contracts.
- Concepts and safety: styles, wrapping choices, and preservation rules.
- Platform compatibility: supported environments and file behavior.
Development
See the development guide for pinned CI dependencies and lock updates.
From the checkout, run make check for repository checks. Run make format to apply the
repository's formatters. The Makefile also provides make install, make reinstall, and
make test; install targets use uv.
License
Docwrap is available under the MIT License.
Release files for docwrap 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| docwrap-0.1.0.tar.gz | 142.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| docwrap-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 307.1 kB
Release files / docwrap-0.1.0.tar.gz
| Download URL | docwrap-0.1.0.tar.gz |
|---|---|
| Size | 142.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
74afb17c462c632ea281e5ea0ed83f765f174c8bf75ec53ea4061b34bed3d289
|
|
BLAKE2b-256 checksum How to use checksums |
3c1c930f95fde0ab8752586fcef6d77eefcf2bc21cf070cc018850f7cc5ff569
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 30, 2026.
Transparency logRelease files / docwrap-0.1.0-py3-none-any.whl
| Download URL | docwrap-0.1.0-py3-none-any.whl |
|---|---|
| Size | 164.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b414d9ac46a3a42ae6fbd89c7702472b7387248064487041fdd19f15b45ad8f
|
|
BLAKE2b-256 checksum How to use checksums |
8c1768cdfe4085d9b06e5e12ffe2882e9ba2bddf7ff3a68b61512efbb4507b89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 30, 2026.
Transparency log