问题描述
我尝试auto docstring
项目中的每个模块功能,但是sphinx-apidoc
无法读取我的函数和文档字符串。
我的项目结构是这样的
mktpip
├── docs
│ ├── Makefile
│ ├── build
│ ├── make.bat
│ └── source
│ ├── _static
│ │ └── logo.jpg
│ ├── _templates
│ ├── conf.py
│ ├── index.rst
│ └── reference
│ ├── me.rst
│ └── modules.rst
├── mktpip
│ ├── __init__.py
│ ├── __init__.pyc
│ └── me
|. |- my_module.py
│ └── __init__.py
├── run.py
├── setup.cfg
└── setup.py
我尝试自动进行文档记录的来源是mktpip/me/my_module.py
,它具有类似这样的简单功能
def my_module(a,b):
"""Calculate two number
Args:
a (int): operand 1
b (int): operand 2
Returns:
int: sum of a + b
"""
return a+b
要自动生成文档字符串,我执行了以下步骤:
(venv) ➜ mktpip copy git:(dev) ✗ sphinx-apidoc -f -o docs/source/reference mktpip/me
Creating file docs/source/reference/me.rst.
Creating file docs/source/reference/modules.rst.
然后,我从*.rst
个文件中生成了HTML
(venv) ➜ docs git:(dev) ✗ make clean && make html
Removing everything under 'build'...
Running Sphinx v1.8.5
making output directory...
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 31 source files that are out of date
updating environment: 31 added,0 changed,0 removed
/Users/narun/Documents/mktpip/venv/lib/python2.7/site-packages/sphinx/util/nodes.py:94: FutureWarning:
The iterable returned by Node.traverse()
will become an iterator instead of a list in Docutils > 0.16.
for classifier in reversed(node.parent.traverse(nodes.classifier)):
然后,我打开一个index.html
文件,发现它没有读取模块me
的功能
(venv) ➜ docs git:(dev) ✗ open build/html/index.html
这是输出:
没有我的函数my_module()
及其docString。
在conf.py
里面,我添加了
docs_dir = os.path.dirname(os.path.dirname(__file__))
sys.path.insert(0,docs_dir)
除上述内容外,此处me.rst
me package
==========
Submodules
----------
me.my\_module module
--------------------
.. automodule:: mktpip.me.my_module
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: mktpip.me
:members:
:undoc-members:
:show-inheritance:
这是怎么了?请帮助我,谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)