文档串生成器

doq的Python项目详细描述


https://github.com/heavenshell/py-doq/workflows/build/badge.svgPython 3Updates

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 nameDescription
class.txtclass docstring
def.txtdef / method docstring
noarg.txtdef / method without argument docstring

可用Jinja2的变量

^{tb2}$

examples

许可证

新的BSD许可证。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在某些练习中避免索引异常   java Android,如何在具有socket的网络区域上提高性能?   更改web中的执行顺序后,JavaServlet过滤器不起作用。xml   java如何绑定泛型类?   JavaGmail RESTAPI:使用Google凭证而不模拟   java是解码整数序列的最快方法   java根据hashmaps的值(通过map的值进行比较)对hashmaps的数组列表进行排序   用于JBoss 7.1或Apache的java负载平衡器,带有Healt检查   java非常慢的MySQL读取性能   java如何在使用iRetryAnalyzer时从Windows CMD关闭Selenium WebDriver?   java随机闪烁仅出现在Galaxy Note 4上   java AttributeOverride MappedSuperClass属性的类型不同   java JPA:如何检测现有实体是否已更新?   java如何使用mavenassemblyplugin从dependencySet中删除METAINF?   安装SecurityManager时,java MQQueueManager构造函数挂起