Sphinx找不到特定目录中的模块 [英] Sphinx doesn't find the modules from a specific directory

查看:27
本文介绍了Sphinx找不到特定目录中的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Python中遇到了一个关于Sphinx的问题。即使我按照https://groups.google.com/forum/#!topic/sphinx-users/lO4CeNJQWjg中的说明操作,我也无法解决它。

我有Docs/SOURCE文件夹,其中包含:

  1. conf.py
  2. index.rst
  3. RstFiles(包含每个模块的.rst文件的文件夹)。
在conf.py中,我通过以下方式指定abs路径: sys.path.insert(0, os.path.abspath('..'))

在index.rst中,我通过以下方式调用RstFiles文件夹中的所有模块:

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

   BatchDataContainer.rst
   BatchDefaultValues.rst
   BatchTypes.rst

最后,每个.rst文件的内容如下:

BatchDataContainer 
==================
.. automodule:: RstFiles.BatchDataContainer
   :members:

运行sphinx-Build时,我收到两个主要错误:

D:hfToolsProjectsValidation-SourceDocssourceRstFilesBatchDataContainer.rst: 警告:文档未包含在任何目录树中

警告:AUTODOC:无法从导入模块‘BatchDataContainer’ 模块""RstFiles"";引发了以下异常:没有名为 "RstFiles"

您知道出了什么问题吗?因为我已经尝试了不同的方法,但都没有效果?

推荐答案

如果conf.py位于此目录中,

D:hfToolsProjectsValidation-SourceDocssource

和项目的Python模块(包括BatchDataContainer.py)位于

D:hfToolsProjectsValidation-SourceProducts

然后您需要sys.path.insert(0, os.path.abspath('../..'))在conf.py中。

automodule指令也需要更新:

.. automodule:: Products.BatchDataContainer
   :members:

这篇关于Sphinx找不到特定目录中的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆