Sphinx python模組自動生成文件

2021-08-15 08:01:33 字數 895 閱讀 4300

安裝

pip install sphinx
假設現在我們有乙個叫run.py的檔案,如下

# run.py

defrun

(name):

""" this is how we run

:param name name of people who runs

"""print name, 'is running'

.. toctree::

:maxdepth: 2

:caption: contents:

introduction

**********==

this is the introduction of demo。

api===

.. automodule:: run

:members:

indices and tables

***************===

* :ref:`genindex`

* :ref:`modindex`

* :ref:`search`

將demo目錄加入sys.path,所以現在開啟conf.py,新增如下內容

import os

import sys

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

執行sphinx生成html文件

sphinx-build

-b html source build

make html

開啟build/html/index.html就可以看到如下介面了

sphinx python 使用及國際化設定

我寫了乙個sphinx python 生成文件的demo,包括國際化。git位址 專案中的引數都是我已經配置好的,source static是專案的靜態檔案目錄包括css,js,img 我在專案中引入了default.css 和 default.js兩個檔案作為預設的樣式和指令碼檔案。所以如果大家對...

python之readline模組 實現自動補全

readline可以實現在python編輯器命令輸入的時候實現自動補全,輸入命令時可以使用上下鍵 刪除鍵等 wget no check certificate pip install readline 6.2.4.1.tar.gz這樣就把python自動補全的功能安裝完畢 如果想啟動python編輯...

pycharm中匯入自寫模組時,模組下出現紅線

問題描述 在pycharm中匯入自己寫的模組時,得不到智慧型提示,並在模組名下出現下紅線,但是 可以執行,錯誤提示為下圖所示 原因 出現 以上情況,是因為檔案目錄設定的問題,pycharm中的最上層資料夾是專案資料夾,在專案中導包預設是從這個目錄下尋找,當在其中再次建立目錄,目錄內的py檔案如果要匯...