Sphinx`make html`缺少模块文档吗?

时间:2018-12-05 19:43:06

标签: python documentation python-sphinx

我第一次尝试使用Sphinx来记录我的python项目,但由于某些应自动进行文档处理的模块在html输出中丢失而被卡住了。这是我的目录结构:

├── project1
│   └── lib
│       ├── a.py
│       └── b.py
├── project2
│   └── lib
│       ├── c.py
│       └── d.py
└── docs
    ├── Makefile
    ├── build
    │   ├── doctrees
    │   └── html
    └── source
        ├── conf.py
        └── index.rst

a.py b.py c.pyd.py中定义了一些类。 为了使狮身人面像正常工作,我专门将以下几行添加到conf.py中:

sys.path.insert(0, os.path.abspath('../../project1/lib'))
sys.path.insert(0, os.path.abspath('../../project2/lib'))

index.rst看起来像这样

Welcome to project1&2's documentation!
=================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:

project1
==========

lib-a
==============
.. automodule:: a
    :members:

lib-b
==============
.. automodule:: b
    :members:

project2
==========

lib-c
==============
.. automodule:: c
    :members:

lib-d
==============
.. automodule:: d
    :members:
Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

在html输出中,我仅看到a.pyd.py的文档。 b.pyc.py中的所有类文档均丢失。我在哪里做错了?还是这是一个错误?非常感谢。

[编辑],当我在html主页底部检查了Indices and tables时,bc的模块链接在那里,但其文档内容却从主页中丢失了。页面。

[EDIT]很抱歉,我没有将文档字符串直接放在class名称下,而是将其放在__init__下。在某种情况下,Sphinx不知何故认为整个课程都没有记录。将类文档字符串移动到class定义下方之后,所有文档字符串成员都将自动进行文档化。

0 个答案:

没有答案