Skip to main content

Generate Docstrings with type-hint informations

Project description

docstring_generator

Auto generate docstring from type-hints.

Usage

You can run this directly from the terminal

gendocs folder/example_file.py

Example

Here a before and after example

example_file.py

Before:

from typing import Dict
from typing import Literal
from typing import Union


def foo(
    val_a: Literal["foo", "bar"],
    val_b: Dict[str, Union[int, float]],
    val_c: str = "Hello World",
) -> Dict[str, Union[int, float]]:
    """
    Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
    sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
    """


def bar(val_a: int, val_b: int) -> int:
    pass


class Vehicle:
    """
    The Vehicle object contains lots of vehicles
    """

    def __init__(self, arg: str, *args, **kwargs):
        """
        $2 at least one value of type string is needed
        """
        self.arg = arg

    def cars(self, distance: float, destination: str):
        pass

    def fuel(self, fuel):
        """
        Some text
        """
        pass

After:

from typing import Dict
from typing import Literal
from typing import Union


def foo(
    val_a: Literal["foo", "bar"],
    val_b: Dict[str, Union[int, float]],
    val_c: str = "Hello World",
) -> Dict[str, Union[int, float]]:
    """
    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 `str` allowed values are `foo` or `bar`
    val_b : argument of type Dict(str, int or float)
    val_c : argument of type str
    	Default is Hello World
    
    Returns
    -------
    Dict(str, int or float)
    """


def bar(val_a: int, val_b: int) -> int:
    """
    Function bar
    
    
    Parameters
    ----------
    val_a : argument of type int
    val_b : argument of type int
    
    Returns
    -------
    int
    """
    pass


class Vehicle:
    """
    The Vehicle object contains lots of vehicles
    
    
    Parameters
    ----------
    arg : argument of type str
    args : variadic arguments of type tuple
    	at least one value of type string is needed
    kwargs : variadic keyword arguments of type dict
    """

    def __init__(self, arg: str, *args, **kwargs):
        """
        $2 at least one value of type string is needed
        """
        self.arg = arg

    def cars(self, distance: float, destination: str):
        """
        Function cars
        
        
        Parameters
        ----------
        distance : argument of type float
        destination : argument of type str
        """
        pass

    def fuel(self, fuel):
        """
        Some text
        """
        pass

Options

  • --style [numpy, rest]
  • --ignore-classes
  • --ignore-functions
  • --help

Installation

  • pip install docstring_generator

Versioning

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

Authors

  • Felix Eisenmenger

License

  • This project is licensed under the MIT License - see the LICENSE.md file for details

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-0.1.0b0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

docstring_generator-0.1.0b0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file docstring_generator-0.1.0b0.tar.gz.

File metadata

  • Download URL: docstring_generator-0.1.0b0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for docstring_generator-0.1.0b0.tar.gz
Algorithm Hash digest
SHA256 a68d5ec13e6758ddbd35b544987e334e9ca25f7d48f48662819192982de5a758
MD5 63d22109ddeb7db8cfa55034f5f6bbc5
BLAKE2b-256 9a0e49ad25be1f872ffa425f7931bb44ae9d0d634070480326f05f1555a56ef7

See more details on using hashes here.

File details

Details for the file docstring_generator-0.1.0b0-py3-none-any.whl.

File metadata

  • Download URL: docstring_generator-0.1.0b0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for docstring_generator-0.1.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 05b8d11d7be48eb2946b4c58fd30ea4577da07d98e12e0abde876892913728fc
MD5 3105da42b39e2ccf284a866ddaeff685
BLAKE2b-256 567eb44fc18ad334df63bc95495728d4b83165ac5cd50f3336f990ef05d7223d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page