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.
Metadata
Release files for doq 0.10.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| doq-0.10.0.tar.gz | 14.9 kB | Without provenance | Details for doq-0.10.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| doq-0.10.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for doq-0.10.0-py2.py3-none-any.whl |
Total release size: 31.6 kB
Release files / doq-0.10.0.tar.gz
| Download URL | doq-0.10.0.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
672b80c1aeb9f02cda3bcbe95b3046e96319385820bacc70662cc486f4c34a86
|
|
BLAKE2b-256 checksum How to use checksums |
bc625d0ac8652ecfaf4470b22db21ca281c3c4dc2db47de8273ec46b4f99183a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / doq-0.10.0-py2.py3-none-any.whl
| Download URL | doq-0.10.0-py2.py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
19b4a3b776b14f4fbe150fb271e177a5443d563e8de12c4853eee4c1c81992f3
|
|
BLAKE2b-256 checksum How to use checksums |
3b5a6bed88a117a245cb1a2ba611013226fd8a89a347224b6bad17dd6fc99f3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for doq 0.10.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.