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

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.0a2.tar.gz (3.7 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.0a2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wrap_docstrings-0.1.0a2.tar.gz
  • Upload date:
  • Size: 3.7 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.0a2.tar.gz
Algorithm Hash digest
SHA256 9da2514af742f443c7dd46d010fb09d7f7ce4b3cb89f598229fe9f0ce7e46247
MD5 d393844d6a4c9fe6eb0d6ee824d99321
BLAKE2b-256 3933b41d92d91dfff5879ea62be453b9d9727a4116285dae5b9dca8efd1ade9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for wrap_docstrings-0.1.0a2.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.0a2-py3-none-any.whl.

File metadata

File hashes

Hashes for wrap_docstrings-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 8a6c6033b16477fcdbe1966546407259178b9f3cb3ca5bb6d6f9c0010107b7db
MD5 df0cd5816f7bb6e66664890a3f7b7cdf
BLAKE2b-256 46bbbdd5812217d33ad055ef55a5a19f6b80a12e63437a803da6fdbb19db7e3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for wrap_docstrings-0.1.0a2-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