首页 > 解决方案 > 具有相同结构的多个模块的 Python Sphinx

问题描述

我有一个文件夹结构:

folder
  foo
    src
      __init__.py
      folder1
        __init__.py
        fileA.py
        fileB.py
  bar
    src
      __init__.py
      folder1
        __init__.py
        fileA.py
        fileB.py

在 fileA 的代码中,我导入了类似的内容: from src.folder1.fileA import something

当我尝试记录这些文件时,未导入其中一个模块。

conf.py

sys.path.insert(0, os.path.abspath('../../folder/foo/'))
sys.path.insert(1, os.path.abspath('../../folder/bar/'))

在 HTML 页面中显示某些内容的唯一方法是使用:

.. automodule:: src.folder1.fileB

但是当我运行 make 时,只有一个函数的描述会同时显示给 html 页面中的 foo 和 bar 。

是否对文档进行任何更改以不更改代码中的导入?

标签: pythondocumentationpython-sphinx

解决方案


推荐阅读