sphinx-doc 配置

安装

依赖python,我一般使用python3

1
pip3 install -U Sphinx

快速使用

创建项目

提供了一个命令进行项目创建sphinx-quickstart,参考quickstart

1
2
3
4
5
6
7
8
9
10
11
12
sphinx-quickstart demo
tree demo
# 目录结构如下
demo
|-- Makefile
|-- build
|-- make.bat
`-- source
|-- _static
|-- _templates
|-- conf.py
`-- index.rst

主题设置

官方自带一些主题,可以到官方文档查阅。
这里使用sphinx_rtd_theme,使用下面的命令进行安装

1
2
3
4
5
pip3 install sphinx_rtd_theme
vi demo/source/conf.py
# 修改html_theme,并添加html_theme_path
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

构建

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cd demo
make html
tree build -L 2
###
build
├── doctrees
│ ├── environment.pickle
│ └── index.doctree
└── html
├── _sources
├── _static
├── genindex.html
├── index.html
├── objects.inv
├── search.html
└── searchindex.js

访问

demo