Skip to main content

Add your description here

Project description

Wrap Docstrings

Currently limited to only wrapping the argument descriptions in Google-style docstrings.

Installation

# Install from PyPI.
uv tool install wrap-docstrings

# Install from source.
git clone https://github.com/btjanaka/wrap-docstrings
cd wrap-docstrings
uv tool install .

Usage

# This command should now work:
wrap-docstrings --help

# To format a file (must have .py extension):
wrap-docstrings file.py

# To format a directory:
wrap-docstrings DIRECTORY

# To read from stdin and write to stdout:
wrap-docstrings -

# To change width and indentation (the default values are shown below):
wrap-docstrings file.py --width 88 --indent 4

Example

This text:

def f(x, y):
    """Does stuff.

    Args:
        x: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure do
        y: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
            eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
            ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
            aliquip ex ea commodo consequat. Duis aute irure do

    Returns:
        Returns are not formatted (for now, at least).
    """
    return x

Becomes:

def f(x, y):
    """Does stuff.

    Args:
        x: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
            tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
            quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
            consequat. Duis aute irure do
        y: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
            tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
            quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
            consequat. Duis aute irure do

    Returns:
        Returns are not formatted (for now, at least).
    """
    return x

Integration with Neoformat

If you are using Neoformat in vim, you can configure this program as a formatter with:

let g:neoformat_python_wrap_docstrings = {
      \ 'exe': 'wrap-docstrings',
      \ 'args': ['-'],
      \ 'stdin': 1,
      \ }
let g:neoformat_enabled_python = ['wrap_docstrings'] " Or append wrap_docstrings to your current list of formatters.

Suppression

To skip a file, add this comment somewhere in the file:

# wrap-docstrings: disable

Development

To get set up:

uv sync --locked --all-extras --dev
uv run pre-commit install

For publishing, this project uses the "trusted publishers" setup between GitHub Actions and PyPI; see here and here for more info. To publish a release, bump the version with uv version and commit the repo with the bumped version. Then, push a tag with the version number; the tag will trigger publishing.

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

wrap_docstrings-0.1.0a3.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

wrap_docstrings-0.1.0a3-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file wrap_docstrings-0.1.0a3.tar.gz.

File metadata

  • Download URL: wrap_docstrings-0.1.0a3.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wrap_docstrings-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 07b204bea08abcb11c90b7d9b75d522e76409af8a2e6ff3344438a36a9856997
MD5 3b6d635a398abb9ab095afab9b95cde7
BLAKE2b-256 ef1ea8b39563eb1391327ff996b47dc5be80ab5ae7144e1b14a78d99a435c6b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for wrap_docstrings-0.1.0a3.tar.gz:

Publisher: ci.yml on btjanaka/wrap-docstrings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wrap_docstrings-0.1.0a3-py3-none-any.whl.

File metadata

File hashes

Hashes for wrap_docstrings-0.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 b2647f0906356990cbcd0e97629c533edf065775316d4bc8c1157d9af53053d4
MD5 29140b4f93696abe0b09c17c26ab5398
BLAKE2b-256 7b98bb6c6d669164b9341583c37d5a6f57ce42c1c3bfe7b7ba2d12efc4ef7b1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for wrap_docstrings-0.1.0a3-py3-none-any.whl:

Publisher: ci.yml on btjanaka/wrap-docstrings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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