Docstrings¶
Docstrings are used to document your CLI.
ReST-style and Google-style docstrings are supported - use whichever you prefer the look of, as functionally they are basically the same.
ReST¶
def say_hello(name: str):
"""
Say hello to someone.
:param name: The person to say hello to.
"""
print(f'hello {name}')
Google¶
def say_hello(name: str):
"""
Say hello to someone.
Args:
name:
The person to say hello to.
"""
print(f'hello {name}')
Output¶
Targ automatically documents your API using the docstring:
python main.py say_hello --help
say_hello
Say hello to someone.
Usage:
say_hello name
Args:
name The person to say hello to.