Compose docstrings with repeated arguments
Project description
Use DocHelper
to simplify your docstrings
I have been writing many functions with shared arguments (or to pass through - not a big fan of the implicit **kwargs
), where documenting or updating these repeated arguments is tedious and error-prone. So how about a centralized place to keep your arguments so you only update once?
DocHelper
solved this problem by keep the docstring for arguments (or other objects) in the same place and compose the docstring in Google format for your functions/classes when you need them.
Usage
from DocHelper import DocHelper
my_doc = DocHelper(
arg1='Just an simple argument',
arg2=('Also an simple argument'),
arg3=('int', 'This argument is integer')
)
@my_doc.compose("""This is my awesome function
Args:
<<arg1, arg2, arg3>>
""")
def awesome_function(arg1, arg2, arg3):
# getting your job down
@my_doc.compose("""This is another awesome function only takes arg1, arg3, and I want indent = 8
Args:
<<arg1, arg2, 8>>
""")
def another_awesome_function(arg1, arg3):
# getting your job down
return 0
>>> awesome_function.__doc__
This is my awesome function
Args:
arg1: Just an simple argument
arg2: Also an simple argument
arg3 (int): This argument is integer
>>> another_awesome_function.__doc__
This is another awesome function only takes arg1, arg3
Args:
arg1: Just an simple argument
arg3 (int): This argument is integer
TODO
- Include different formatting (Numpy, reStructuredText)
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for doc_helper-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 435f348624fba18110b9abde660295f705b6a51a69bae06f07815a0d8500e91a |
|
MD5 | 834219b20da04b6e27fd9df888a8ae4a |
|
BLAKE2b-256 | da9333d9749eaeed689ea7ae89ee1168389dd673877613da8f0c9f1ca8f15db8 |