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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for docstring_generator-0.1.0b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a68d5ec13e6758ddbd35b544987e334e9ca25f7d48f48662819192982de5a758 |
|
MD5 | 63d22109ddeb7db8cfa55034f5f6bbc5 |
|
BLAKE2b-256 | 9a0e49ad25be1f872ffa425f7931bb44ae9d0d634070480326f05f1555a56ef7 |
Close
Hashes for docstring_generator-0.1.0b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05b8d11d7be48eb2946b4c58fd30ea4577da07d98e12e0abde876892913728fc |
|
MD5 | 3105da42b39e2ccf284a866ddaeff685 |
|
BLAKE2b-256 | 567eb44fc18ad334df63bc95495728d4b83165ac5cd50f3336f990ef05d7223d |