Sphinx 找不到特定目录中的模块
我在 Python 中遇到了 Sphinx 的问题。即使我已按照 https://groups.google 的说明进行操作。 com/forum/#!topic/sphinx-users/lO4CeNJQWjg 我无法解决它。
我有 Docs/source 文件夹,其中包含:
- conf.py
- index.rst
- 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 时,出现 2 个主要错误:
D:\hfTools\Projects\Validation-Source\Docs\source\RstFiles\BatchDataContainer.rst: 警告:文档不包含在任何目录树中
并且
警告:autodoc:无法从以下位置导入模块“BatchDataContainer” 模块“RstFiles”;引发以下异常:没有名为的模块 “第一个文件”
有什么想法可能是错误的,因为我已经尝试了不同的方法但没有任何帮助?
I have faced a problem with Sphinx in Python. Even if I have followed the instructions from https://groups.google.com/forum/#!topic/sphinx-users/lO4CeNJQWjg I was not able to solve it.
I have Docs/source folder which contains:
- conf.py
- index.rst
- RstFiles (the folder which contains .rst files for each module).
In conf.py I specify the abs path in the following way:sys.path.insert(0, os.path.abspath('..'))
In index.rst I call all the modules from RstFiles folder in the following way:
.. toctree::
:maxdepth: 2
:caption: Contents:
BatchDataContainer.rst
BatchDefaultValues.rst
BatchTypes.rst
And finally, the content of each .rst file is in the following way:
BatchDataContainer
==================
.. automodule:: RstFiles.BatchDataContainer
:members:
When I run sphinx-build I get 2 main errors:
D:\hfTools\Projects\Validation-Source\Docs\source\RstFiles\BatchDataContainer.rst:
WARNING: document isn't included in any toctree
and
WARNING: autodoc: failed to import module 'BatchDataContainer' from
module 'RstFiles'; the following exception was raised: No module named
'RstFiles'
Any ideas what might be wrong cause I have tried different things already and nothing has helped?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果conf.py位于此目录中,则
D:\hfTools\Projects\Validation-Source\Docs\source,
并且项目的Python模块(包括BatchDataContainer.py)位于
D: \hfTools\Projects\Validation-Source\Products,
那么你需要
sys.path.insert(0, os.path.abspath('../..'))
在conf.py。automodule
指令也需要更新:If conf.py is located in this directory,
D:\hfTools\Projects\Validation-Source\Docs\source,
and the project's Python modules (including BatchDataContainer.py) are in
D:\hfTools\Projects\Validation-Source\Products,
then you need
sys.path.insert(0, os.path.abspath('../..'))
in conf.py.The
automodule
directive needs to be updated as well: