文档串生成器
doq的Python项目详细描述
Docstring生成器。在
安装
$ pip install doq
如何使用
^{pr2}$$ cat spam.py | doq def spam(arg1, arg2: str) -> str: """spam. :param arg1: :param arg2: :type arg2: str :rtype: str """ pass
默认格式化程序是sphinx。您可以选择斯芬克斯、谷歌或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
使用
$ 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] [--ignore_exception] [--ignore_yield] 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 Dire -w, --write Edit files in-place -v, --version Output the version number --ignore_exception Ignore exception statements --ignore_yield Ignore yield statements
自定义模板
doq使用Jinja2模板。所以你可以创建自己的模板。在
注意
必须创建3个文件模板。在
File name | Description |
---|---|
class.txt | class docstring |
def.txt | def / method docstring |
noarg.txt | def / method without argument docstring |
可用Jinja2的变量
^{tb2}$许可证
新的BSD许可证。在
- 项目
标签: