Sphinx and argparse - autodocumenting command line scripts?

…衆ロ難τιáo~ 提交于 2019-11-28 08:57:45

You can use sphinxcontrib.programoutput to include the help messages from the command line in your documentation.

This is not specific to argparse but can be used to document any script printing help messages to the command line.

Use sphinx-argparse extension:

http://sphinx-argparse.readthedocs.org/en/latest/

You can use sphinxcontrib.autoprogram. pip install sphinxcontrib-autoprogram, then put

extensions += ['sphinxcontrib.autoprogram']

in your conf.py. To document command cli.py by importing cli with the argparse parser object parser (which can be a Python expression, like a function get_parser()), use

.. autoprogram:: cli:parser
   :prog: cli.py
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!