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

时间:2012-10-30 08:22:53

标签: python documentation python-sphinx restructuredtext

我如何在sphinx中定义应该使用哪个.rst文件和目录?

我想在我的测试/构建/文档脚本中包含一个自动文档生成器。 sphinx-quickstart 在我的工作区中执行,并创建了一个index.rst文件。由于sphinx使用重组文本文件作为文档,我在工作区中导航并使用 sphinx-autogen 手动创建它们。它导致了tasks.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:   

tasks.rst

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:

1 个答案:

答案 0 :(得分:4)

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

像这样:

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

Contents:

.. toctree::
   :maxdepth: 2

.. automodule:: tasks.add_to_config
   :members:

.. automodule:: tasks.build_egg
   :members:  

看看是否有帮助。

如果Sphinx仍无法找到要记录的代码,那么您可能需要在PYTHONPATH文件中修改sys.path或更改conf.py以帮助Sphinx找到它正在寻找什么。