Sphinx的autodoc的automodule显然无效

Sphinx的autodoc的automodule显然无效,第1张

Sphinx的autodoc的automodule显然无效

我将尝试通过将“规范”方法与您的案例并列进行回答。

通常的“入门方法”遵循以下步骤:

  1. doc
    在您的目录中创建一个目录
    project
    (从该目录中执行以下步骤中的命令)。

  2. sphinx-quickstart
    (选择分离
    source
    build
    )。

  3. sphinx-apidoc -o ./source ..

  4. make html

这将产生以下结构

C:Project||   agent.py|   |---docs|   |   make.bat|   |   Makefile|   |   |   |---build|   |    |   |---source|       |   conf.py|       |   agent.rst|       |   index.rst|       |   modules.rst

在您

conf.py
要添加的内容中(第2步之后):

sys.path.insert(0, os.path.abspath(os.path.join('..', '..')))

并在

index.rst
您链接
modules.rst

Welcome to Project's documentation!================================.. toctree::   :maxdepth: 2   :caption: Contents:   modulesIndices and tables==================* :ref:`genindex`* :ref:`modindex`* :ref:`search`


现在,将以上内容与您在问题中分享的内容进行比较:

C:Project||   agent.py|   |---apidoc|   |   agent.rst|   |   conf.py|   ||   |-- _build

你跑了:

sphinx-build -b html apidoc apidoc/_build

并在您的

conf.py

sys.path.insert(0, os.path.abspath('.'))


您的错误stacktrace表示找不到模块

agent
。这可能是因为你没有去1级记在你的
conf.py
(它的指向与路径
.rst
,不与路径
.py
),这应该工作
sys.path.insert(0,os.path.abspath('..'))
。另外,如果你没有手动编辑/连接你
modules.rst
在你的
index.rst
你很可能只看到该模块。



您可能会注意到在运行中sphinx命令的签名:

sphinx-apidoc [OPTIONS] -o <OUTPUT_PATH> <MODULE_PATH>sphinx-build [options] <sourcedir> <outputdir> [filenames …]

<sourcedir>
指在哪里
.rst
<MODULE_PATH>
在哪里
.py
<OUTPUT_PATH>
到哪里
.rst
放置,
<outputdir>
到哪里
.html
放置。

还请注意,您提到:“该项目的目录为当前工作目录。”
我已经在的sphinx线程中看到了“工作目录”,可以同时作为

Project
基本目录或
docs
目录使用。但是,如果您在Sphinx文档中搜索“工作目录”,则不会提及它。

最后,使用“入门方法”的文件/目录结构有一个优势。基本上,Sphinx标记上的大多数线程都“将您置于同一页上”,从而减轻了将案例映射到不同目录/文件结构的工作量。

我希望这有帮助。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5616827.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存