Skip to main content

Auto generate docstring from type-hints.

Project description

Python 3.10 PyPI version Ruff uv

docstring_generator

Auto generate docstring from type-hints for python functions and class methods.

How to use it

gendocs_new file.py
gendocs_new mydir/

Options

style

  • --style
  • Docstring style [numpy, google, rest]. [default: numpy]

Add additional information before running gendocs_new

  • when adding $<num> into your docstring these will then be replaced with parameter at this index
  • Example:
from typing import List


def foo(val_a: int, val_b: List[int]):
    """
    Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
    sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam

    $1 Lorem ipsum dolor sit amet
    $2 nonumy eirmod tempor invidun
    """

will become (here with numpy style)

from typing import List


def foo(val_a: int, val_b: List[int]):
    """
    Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
    sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
    
    Parameters
    ----------
    val_a : argument of type int
        Lorem ipsum dolor sit amet
    val_b : argument of type List(int)
        nonumy eirmod tempor invidun

    """

FAQ

what happens if I re-run the docstring creation?

  • nothing if all stays the same, changed parameter descriptions will be ignored only changes of the function header will be used

Examples

  • An example can be found under examples

Installing

  • pip install docstring-generator

Dependency

Versioning

  • For the versions available, see the tags on this repository.

Authors

  • Felix Eisenmenger

License

  • MIT License (MIT)

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

docstring_generator-1.0.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

docstring_generator-1.0.2-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file docstring_generator-1.0.2.tar.gz.

File metadata

  • Download URL: docstring_generator-1.0.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for docstring_generator-1.0.2.tar.gz
Algorithm Hash digest
SHA256 b20d0ff97bdda2e12251cca2591a8418d788d6d5bbbb42ad00ae5f9366176edc
MD5 b54da80910c72f0fed13c23c824f9498
BLAKE2b-256 5448d97eb472cd7627de1fd6d27afbd407a600ae30fe8392fffbdb18686570e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_generator-1.0.2.tar.gz:

Publisher: python-publish.yml on FelixTheC/docstring_generator

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

File details

Details for the file docstring_generator-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for docstring_generator-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1d74a4656844bdcd23ebbbf9087e0a10d59316821963f37fed82a1573b7f82ab
MD5 697d08ae0c8fc5260fae827192daab52
BLAKE2b-256 4dbc19d52ab9b0295d928468ccc38fcbafe8033a49be0e7251a210ac644c8ea3

See more details on using hashes here.

Provenance

The following attestation bundles were made for docstring_generator-1.0.2-py3-none-any.whl:

Publisher: python-publish.yml on FelixTheC/docstring_generator

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