sphinx 记录:.py 文件在 sphinx 根之外

sphinx documenting: .py file outside of the sphinx root

我需要一些关于 sphinx 文档生成器的帮助 我的 git 存储库如下所示:

根目录:

.. include:: ../../repo/boot.py

Boot file
==========

我在 index.rst 中的 toctree 看起来像这样:

.. toctree::
   :maxdepth: 2
   :caption: source code:
   
   Boot file <boot_link.rst>

现在 Spinx 可以读取我的 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:

我想就是这样。