Docstring generator
Project description
Docstring generator.
Installation
$ pip install doq
How to use
$ cat spam.py
def spam(arg1, arg2: str) -> str:
pass
$ cat spam.py | doq
def spam(arg1, arg2: str) -> str:
"""spam.
:param arg1:
:param arg2:
:type arg2: str
:rtype: str
"""
pass
Default formatter is sphinx. You can choose sphinx, google or numpy.
$ cat spam.py | doq --formatter=google
def spam(arg1, arg2: str) -> str:
"""spam.
Args:
arg1 : arg1
arg2 (str): arg2
Returns:
str:
"""
pass
$ cat spam.py | doq --formatter=numpy
def spam(arg1, arg2: str) -> str:
"""spam.
Parameters
----------
arg1
arg1
arg2 : str
arg2
Returns
-------
str
"""
pass
Usage
$ python -m doq.cli --help
usage: doq [-h] [-f FILE] [--start START] [--end END] [-t TEMPLATE_PATH]
[-s STYLE] [--formatter FORMATTER] [--indent INDENT] [--omit OMIT]
[-r] [-d DIRECTORY] [-w] [-v] [-c CONFIG] [--ignore_exception]
[--ignore_yield] [--ignore_init]
Docstring generator.
optional arguments:
-h, --help show this help message and exit
-f FILE, --file FILE File or STDIN
--start START Start lineno
--end END End lineno
-t TEMPLATE_PATH, --template_path TEMPLATE_PATH
Path to template directory
-s STYLE, --style STYLE
Output style string or json
--formatter FORMATTER
Docstring formatter. sphinx,google or numpy
--indent INDENT Indent number
--omit OMIT Omit first argument such as self
-r, --recursive Run recursively over directories
-d DIRECTORY, --directory DIRECTORY
Path to directory
-w, --write Edit files in-place
-v, --version Output the version number
-c CONFIG, --config CONFIG
Path to a setup.cfg or pyproject.toml
--ignore_exception Ignore exception statements
--ignore_yield Ignore yield statements
--ignore_init Ignore generate docstring to __init__ method
Customize template
doq use Jinja2 template. So you can create your own template.
File name |
Description |
---|---|
class.txt |
class docstring |
def.txt |
def / method docstring |
noarg.txt |
def / method without argument docstring |
Available Jinja2’s variable
Name |
Description |
|
---|---|---|
name |
class, method, def’s name |
|
params |
argument |
Method, def’s argument |
annotation |
Argument’s type hint |
|
default |
Defaut keyword argument |
|
exceptions |
List of exception |
|
yields |
List of yield |
|
return_type |
Return type hint |
See examples
Configuration
doq will automatically search setup.cfg or pyproject.toml in your project.
setup.cfg
The section must be [doq].
configuration file example:
[doq] style = "json" template_path = "/path/to/template"
pyproject.toml
The section must be [tool.doq].
configuration file example:
[tool.doq] style = "json" template_path = "/path/to/template"
Completion
This program provides shell completions. It should be out of box if you install it from a wheel file.
LICENSE
NEW BSD LICENSE.
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 doq-0.10.0.tar.gz
.
File metadata
- Download URL: doq-0.10.0.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 672b80c1aeb9f02cda3bcbe95b3046e96319385820bacc70662cc486f4c34a86 |
|
MD5 | 9cb00c1151225d0c4fa4fa988785b673 |
|
BLAKE2b-256 | bc625d0ac8652ecfaf4470b22db21ca281c3c4dc2db47de8273ec46b4f99183a |
File details
Details for the file doq-0.10.0-py2.py3-none-any.whl
.
File metadata
- Download URL: doq-0.10.0-py2.py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19b4a3b776b14f4fbe150fb271e177a5443d563e8de12c4853eee4c1c81992f3 |
|
MD5 | 20883db57adef7b161efdfd5a437fdcd |
|
BLAKE2b-256 | 3b5a6bed88a117a245cb1a2ba611013226fd8a89a347224b6bad17dd6fc99f3e |