sphinx使用及其簡單配置方法

發布時間:2012年03月18日      浏覽次數:923 次
sphinx使用
進入你要創建文檔的目錄,例如要創建在目錄/home/wwwroot/doc下(xià)
cd /home/wwwroot/doc
開(kāi)始使用向導創建你的文檔項目
sphinx-quickstart
程序會提示輸入一(yī)些選項,如輸入根目錄,大(dà)部分(fēn)使用默認選項,直接按回車(chē)即可。
複制代碼 代碼如下(xià):
Enter the root path for documentation.
> Root path for the documentation [.]:
//輸入跟目錄,直接回車(chē)
You have two options for placing the build directory for Sphinx output.
Either, you use a directory "_build" within the root path, or you separate
"source" and "build" directories within the root path.
> Separate source and build directories (y/N) [n]:
//是否分(fēn)離(lí)source和build目錄,建議選y,方便管理
Inside the root directory, two more directories will be created; "_templates"
for custom HTML templates and "_static" for custom stylesheets and other static
files. You can enter another prefix (such as ".") to replace the underscore.
> Name prefix for templates and static dir [_]:
//直接回車(chē)
The project name will occur in several places in the built documentation.
> Project name: F2E Cookbook
> Author name(s): imbingdian
//輸入項目名稱
//輸入作者名稱
The file name suffix for source files. Commonly, this is either ".txt"
or ".rst". Only files with this suffix are considered documents.
> Source file suffix [.rst]: .txt
//檔文件的擴展名,默認是.rst
//後面的操作基本回車(chē)就好

完成後可以看到doc文件中(zhōng)生(shēng)了以下(xià)目錄文件
build--生(shēng)成文檔目錄
source--源文件目錄
make.bat
makefile
生(shēng)成html文檔
make html
看一(yī)下(xià)build目錄下(xià)是不是生(shēng)成了html文檔了?
^_^ enjoy it!
查看demo:http://doc.litejs.com/
sphinx簡單配置
source目錄下(xià)的conf.py文件爲sphinx的配置文件。
1)修改文檔語言爲中(zhōng)文:
找到#language = None,修改爲:language ='zh_CN',其它語言見下(xià)表
複制代碼 代碼如下(xià):
bn – Bengali
ca – Catalan
cs – Czech
da – Danish
de – German
en – English
es – Spanish
fi – Finnish
fr – French
hr – Croatian
it – Italian
ja – Japanese
lt – Lithuanian
nl – Dutch
pl – Polish
pt_BR – Brazilian Portuguese
ru – Russian
sl – Slovenian
tr – Turkish
uk_UA – Ukrainian
zh_CN – Simplified Chinese
zh_TW – Traditional Chinese


2)設置主題

找到html_theme = 'default',修改default即可。目前官方提供的主題見http://sphinx.pocoo.org/theming.html#builtin-themes

3)其它

還其它更多設置,具體(tǐ)請參考官方文檔。

設置好以後,重新make html即可。
免責聲明:本站相關技術文章信息部分(fēn)來自網絡,目的主要是傳播更多信息,如果您認爲本站的某些信息侵犯了您的版權,請與我(wǒ)(wǒ)們聯系,我(wǒ)(wǒ)們會即時妥善的處理,謝謝合作!