1. SPHINX¶
1.1. 安装¶
在Windows上安装Sphinx
如果你的Windows电脑已经安装好了Python或Pip的话,只需要在CMD窗口中执行
pip install Sphinx。
1.1.1. 更改皮肤conf.py¶
#html_theme = 'alabaster'
import sphinx_rtd_theme
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
1.3. 自动构建¶
1.3.1. sphinx-autobuild¶
pip install sphinx-autobuild
sphinx-autobuild . _build/html \
-p 8000 -H 172.17.0.4 \
--ignore "*.swp" --ignore "*.pdf" --ignore "*.log" --ignore "*.out" --ignore "*.toc" \
--ignore "*.aux" --ignore "*.idx" --ignore "*.ind" --ignore "*.ilg" --ignore "*.tex"
1.3.2. 参数说明¶
- -p
--portoption to specify the port on which the documentation shall be served (default 8000) - -H
--hostoption to specify the host on which the documentation shall be served (default 127.0.0.1) - -i
--ignoremultiple allowed, option to specify file ignore glob expression when watching changes, for example: *.tmp - -B
--open-browser automatically open a web browser with the URL for this document --no-initialdisable initial build- -s
--delaydelay in seconds before opening browser if –open-browser was selected (default 5) - -z
--watchmultiple allowed, option to specify additional directories to watch, for example: some/extra/dir
1.3.3. Makefile integration¶
To integrate the sphinx-autobuild command in the Makefile generated by Sphinx, add the following target:
livehtml:
sphinx-autobuild -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
Then run with: make livehtml
1.6. 上传到GitHub¶
1.6.1. master分支¶
# edit .gitignore to ignore _build
echo "_build" >> .gitignore
git add .gitignore
git commit -m 'ignoring _build'
# create a new directory (in doc/)
mkdir -p _build/html
# clone the entire repo into this directory (yes, this duplicates it)
git clone git@github.com:username/project.git _build/html
1.6.2. gh-pages分支¶
# set this directory to track gh-pages
git symbolic-ref HEAD refs/heads/gh-pages
rm .git/index
git clean -fdx
1.6.3. 首次gh-pages分支提交¶
# in docs/, run `make html` to generate our doc, which will fill
# _build/html, but not overwrite the .git directory
cd ../..
make html
# now, add these bad-boys to the gh-pages repo, along with .nojekyll:
cd _build/html
touch .nojekyll
git add .
git commit -m 'first docs to gh-pages'
git push origin gh-pages
# [optional] cleanup stuff in duplicate master (in docs/_build/html)
git checkout master
rm .git/index
git clean -fdx
1.6.4. 日常文档修改提交¶
# now, when you run `make html` and need to update your documentation,
# you can do it "normally" without worrying about the many vagaries of
# submodule syncing (I can never get the order correct). just make
# changes, then:
make html
cd _build/html
git commit -a -m 'made some changes, yo'
git push origin gh-pages
1.7. reStructuredText 语法简介¶
1.7.1. 内联标记¶
- 星号: text 是强调 (斜体),
- 双星号: text 重点强调 (加粗),
- 反引号:
text代码样式.
1.7.2. 列表¶
- 开头放置一个星号和一个缩进. 编号的列表也可以使用符号 # 自动加序号:
这是一个项目符号列表.
- 它有两项,第二项使用两行.
- 这是个有序列表.
- 也有两项.
- 是个有序列表.
- 也有两项.你晚点