I tried to auto docstring
every module functions inside my project, but sphinx-apidoc
does not read my function and doc string.
my project structure is like this
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
The source that I tried to auto-doc from is at mktpip/me/my_module.py
that has a simple function like this
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
To auto docstring, I performed the following steps:
(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.
Then, I generated the HTML from *.rst
files
(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)):
Then, I open an index.html
file and found it does not read my function of module me
(venv) ➜ docs git:(dev) ✗ open build/html/index.html
This is what the output:
There is no my function my_module()
and its docString.
Inside conf.py
, I added
docs_dir = os.path.dirname(os.path.dirname(__file__))
sys.path.insert(0, docs_dir)
In addition to above, here content of 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:
What went wrong with this? Please kindly help me, thanks.