sphinx 记录:.py 文件在 sphinx 根之外
sphinx documenting: .py file outside of the sphinx root
我需要一些关于 sphinx 文档生成器的帮助
我的 git 存储库如下所示:
根目录:
- 文档(关于 sphinx 的东西)
- 代码(用于 micropython 的东西)
问题是 spinx 不能真正使用根目录之外的文件。
但没问题(我想,在深入研究了最深入的 Whosebug 主题之后)
我创建了一个 boot_link.rst 文件,如下所示。 (我需要添加标题,否则不会生成。)
.. include:: ../../repo/boot.py
Boot file
==========
我在 index.rst 中的 toctree 看起来像这样:
.. toctree::
:maxdepth: 2
:caption: source code:
Boot file <boot_link.rst>
现在 Spinx 可以读取我的 boot.py 文件,但它一团糟。
启动页面如下所示:
- 首先是源代码,原样(所以代码在那里,还有每条评论,基本上是 .py 文件中的每个字符,只是转储在那里)
- 最后是引导文件名。 :D
我可以得到一些帮助如何解决它吗?
根据 boot.py 文件的注释,最终结果应该是一个格式良好的页面。 (我的回购协议中的其余文件也在稍后,因为)
编辑:好的,我找到了解决方案。将此添加到 index.rst:
.. toctree::
:maxdepth: 2
:caption: source code:
autodoc
将此添加到 conf.py
import os
import sys
sys.path.insert(0, os.path.abspath('../../repo/'))
还有这个:
extensions = ['sphinx.ext.autodoc']
最后像这样创建 autodoc.rst:
.. _autodoc:
.. contents::
something.py
=================
.. automodule:: something
:members:
:undoc-members:
something1.py
=================
.. automodule:: something1
:members:
:undoc-members:
something2.py
=================
.. automodule:: something2
:members:
:undoc-members:
我想就是这样。
我需要一些关于 sphinx 文档生成器的帮助 我的 git 存储库如下所示:
根目录:
- 文档(关于 sphinx 的东西)
- 代码(用于 micropython 的东西) 问题是 spinx 不能真正使用根目录之外的文件。 但没问题(我想,在深入研究了最深入的 Whosebug 主题之后) 我创建了一个 boot_link.rst 文件,如下所示。 (我需要添加标题,否则不会生成。)
.. include:: ../../repo/boot.py
Boot file
==========
我在 index.rst 中的 toctree 看起来像这样:
.. toctree::
:maxdepth: 2
:caption: source code:
Boot file <boot_link.rst>
现在 Spinx 可以读取我的 boot.py 文件,但它一团糟。 启动页面如下所示:
- 首先是源代码,原样(所以代码在那里,还有每条评论,基本上是 .py 文件中的每个字符,只是转储在那里)
- 最后是引导文件名。 :D 我可以得到一些帮助如何解决它吗? 根据 boot.py 文件的注释,最终结果应该是一个格式良好的页面。 (我的回购协议中的其余文件也在稍后,因为)
编辑:好的,我找到了解决方案。将此添加到 index.rst:
.. toctree::
:maxdepth: 2
:caption: source code:
autodoc
将此添加到 conf.py
import os
import sys
sys.path.insert(0, os.path.abspath('../../repo/'))
还有这个:
extensions = ['sphinx.ext.autodoc']
最后像这样创建 autodoc.rst:
.. _autodoc:
.. contents::
something.py
=================
.. automodule:: something
:members:
:undoc-members:
something1.py
=================
.. automodule:: something1
:members:
:undoc-members:
something2.py
=================
.. automodule:: something2
:members:
:undoc-members:
我想就是这样。