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
![](images/Peek 2022-09-27 20-20.gif)
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
File details
Details for the file docstring_generator-0.1.1b0.tar.gz
.
File metadata
- Download URL: docstring_generator-0.1.1b0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb5995e1ae04fe1beef6c8a7a5681dcb3292d908561e2bcdb41820aad6a2cd0f |
|
MD5 | 8000d7f1b075aa8086717dd324ce3335 |
|
BLAKE2b-256 | 6ebd37c4443faf3b23d8d98bd0b476629c03ff3b73eed82a6617e36328a0889a |
File details
Details for the file docstring_generator-0.1.1b0-py3-none-any.whl
.
File metadata
- Download URL: docstring_generator-0.1.1b0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfe89b28f2ed28dfd227a1764e9bd1c16d471872241d839f3a5b8798bbb72043 |
|
MD5 | 4c36714a0fc1747aa9c5a53600ad11ac |
|
BLAKE2b-256 | 365cb7dfdcef0d75b1ab12a642d3c6c431ac707efe2f4f6872554f27d01869ce |