我开始研究一个 python 模块,并希望“就地”记录代码。因此,我使用 sphinx-quickstart 在子目录中设置了 sphinx,从而生成了此目录结构(仅显示了我编辑的文件):
我的 index.rst 包含:
Welcome to My Module's documentation!
=====================================
.. toctree::
:maxdepth: 2
:caption: Contents:
.. automodule:: myproject
:members:
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
Run Code Online (Sandbox Code Playgroud)
当我跑
make html
Run Code Online (Sandbox Code Playgroud)
我得到了一个缺少自动模块部分的文档,尽管我记录了 main.py 中的每个类和每个方法,如下所示:
class Thing:
"""This class represents Things
:param color: how the thing should look like
"""
def __init__(self, color):
pass
def color(self):
"""Tells you the color of the thing.
:returns: Color …Run Code Online (Sandbox Code Playgroud)