[英]How to make Sphinx autodoc extension include an underscore/private Python module
[英]how include module in sphinx
一個星期以來,我一直在尋找這個問題的答案。 希望你能幫我:
我正在使用 Sphinx 進行記錄,這是我的項目結構:
-folder
__init__
-main_tool_folder
__init__
main.py
-docs_folder
-modulefolder
__init__
fileIwanttodocument
在我的 main.py 里面
sys.path.append('../')
from modulefolder.fileIwanttodocument import functionIneed
並且代碼有效
當涉及到 Sphinx 時,它失敗了(在我執行導入的行中出錯)
在我的 conf.py 我使用
sys.path.insert(0, os.path.abspath('../'))
sys.path.insert(1, os.path.abspath('../../'))
並在 code.rst
.. automodule:: main
:members
.. automodule:: modulefolder.fileIwanttodocument
:members:
如何包含 fileIwanttodocument.py ? 到目前為止我發現的唯一方法是將它復制到 main_tool_folder 中,這違背了創建模塊的目的
自己解決了! 在 conf.py 之前
sys.path.insert(0, os.path.abspath('../'))
sys.path.insert(1, os.path.abspath('../../'))
我有
sys.path.insert(0, os.path.dirname(os.getcwd()))
這引起了問題。
顯然我的做法是正確的!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.