Python:如何在sphinx中定义应使用哪些.rst文件和目录?

Jon*_*Jon 4 python documentation restructuredtext python-sphinx

如何在sphinx中定义应使用的.rst文件和目录?

我想在测试/构建/文档脚本中包含一个自动文档生成器。 在我的工作空间中执行了sphinx-quickstart,并创建了一个index.rst文件。当sphinx使用重组的文本文件作为文档时,我在工作区中导航并使用sphinx-autogen手动创建它们。结果进入了task.rst文件(见下文)。

当我使用“ make html”时,我会收到一些警告:

警告:自动模块的无效签名(u'tasks / add_to_config')

警告:autodoc无法导入/查找模块'tasks.add_to_config',它报告错误:“没有名为wl_build.tasks的模块”,请检查您的拼写和sys.path

警告:不知道要导入哪个模块以自动记录u'tasks / add_to_config'(尝试在文档中放置“ module”或“ currentmodule”指令,或给出明确的模块名称)

...

我的index.rst

Welcome to build's documentation!
====================================

Contents:

.. toctree::
   :maxdepth: 2

.. automodule:: tasks/add_to_config
   :members:

.. automodule:: tasks/build_egg
   :members:   
Run Code Online (Sandbox Code Playgroud)

任务

tasks Package
=============

:mod:`tasks` Package
--------------------

.. automodule:: tasks.__init__
    :members:
    :undoc-members:
    :show-inheritance:

:mod:`add_to_config` Module
---------------------------

.. automodule:: tasks.add_to_config
    :members:
    :undoc-members:
    :show-inheritance:

:mod:`build_egg` Module
-----------------------

.. automodule:: tasks.build_egg
    :members:
    :undoc-members:
    :show-inheritance:
Run Code Online (Sandbox Code Playgroud)

Kev*_*orn 5

尝试用/句号(.)替换index.rst文件中的字符

像这样:

Welcome to build's documentation!
====================================

Contents:

.. toctree::
   :maxdepth: 2

.. automodule:: tasks.add_to_config
   :members:

.. automodule:: tasks.build_egg
   :members:  
Run Code Online (Sandbox Code Playgroud)

看看是否有帮助。

如果狮身人面像仍然无法代码找到文件,那么你可能需要修改PYTHONPATH或改变sys.path在你的conf.py文件,以帮助狮身人面像查找的寻找。