進入你要創建文檔的目錄,例如要創建在目錄/home/wwwroot/doc下
cd /home/wwwroot/doc
開始使用向導創建你的文檔項目
sphinx-quickstart
程序會提示輸入一些選項,如輸入根目錄,大部分使用默認選項,直接按回車即可。
Enter the root path for documentation.> Root path for the documentation [.]://輸入跟目錄,直接回車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]://是否分離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 staticfiles. You can enter another prefix (such as ".") to replace the underscore.> Name prefix for templates and static dir [_]://直接回車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//後面的操作基本回車就好
完成後可以看到doc文件中生了以下目錄文件
build--生成文檔目錄source--源文件目錄make.bat makefile
生成Html文檔
make Html
看一下build目錄下是不是生成了Html文檔了?
^_^ enjoy it!
source目錄下的conf.py文件為sphinx的配置文件。
找到#language = None,修改為:language ='zh_CN',其它語言見下表
bn – Bengalica – Catalancs – Czechda – Danishde – Germanen – Englishes – Spanishfi – Finnishfr – Frenchhr – Croatianit – Italianja – Japaneselt – Lithuaniannl – Dutchpl – Polishpt_BR – Brazilian Portugueseru – Russiansl – Sloveniantr – Turkishuk_UA – Ukrainianzh_CN – SimplifIEd Chinesezh_TW – Traditional Chinese
找到html_theme = 'default',修改default即可。目前官方提供的主題見sphinx.pocoo.org/theming.Html#builtin-themes
還其它更多設置,具體請參考官方文檔。
設置好以後,重新make Html即可。