相关疑难解决方法(0)

sphinx-build失败 - autodoc无法导入/查找模块

我正试图开始使用Sphinx并且似乎有无情的问题.

命令: docs/sphinx-quickstart

我回答所有问题,一切正常.

命令: docs/ls

一切看起来都很正常.结果:build Makefile source

命令: sphinx-build -d build/doctrees source build/html

它似乎工作.我能够打开index.html文件,看到我想要的"shell".

当我尝试将我的实际源代码作为source文件夹时遇到问题.

命令: sphinx-build -d build/doctrees ../ys_utils build/html

结果:

Making output directory...
Running Sphinx v1.1.3
loading pickled environment... not yet created
No builder selected, using default: html
loading intersphinx inventory from http://docs.python.org/objects.inv...
building [html]: targets for 1 source files that are out of date
updating environment: 1 added, 0 changed, 0 removed
Traceback (most recent call last):                                                                                               
  File "/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/ext/autodoc.py", line 321, in …
Run Code Online (Sandbox Code Playgroud)

python documentation python-sphinx

82
推荐指数
6
解决办法
7万
查看次数

Sphinx 的 autodoc 的 automodule 显然没有效果

我在rst包含automodule但似乎没有任何效果的文件上运行 Sphinx 。

以下是详细信息:我有一个 Python 项目,其中agent.py包含一个包含类的文件Agent。我还有一个子目录,里面apidoc有一个文件agent.rst(由 生成sphinx-apidoc):

agent module
============

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

sphinx-build -b html apidoc apidoc/_build使用项目目录作为当前工作目录运行 sphinx 。

为了确保找到 Python 文件,我在 中包含了以下内容apidoc/conf.py

agent module
============

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

它运行时没有错误,但是当我打开生成的 HTML 文件时,它只显示“代理模块”并且一切都是空白的。为什么不显示类Agent及其成员?

更新:最初的问题很可能是由于我没有包含sphinx.ext.autodocconf.py. 但是,现在我这样做了,我收到了如下警告:

import os
import sys
sys.path.insert(0, os.path.abspath('.'))
Run Code Online (Sandbox Code Playgroud)

python python-sphinx autodoc sphinx-apidoc

4
推荐指数
1
解决办法
1443
查看次数