(venv) ➜ Demo sphinx-quickstart
Welcome to the Sphinx 1.8.1 quickstart utility.
Please enter values for the following settings (just press Enter to
accept a default value, if one is given in brackets).
Selected root path: .
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]: 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 [_]:
The project name will occur in several places in the built documentation.
> Project name: Demo
> Author name(s): vae
> Project release []: 1.0.0
If the documents are to be written in a language other than English,
you can select a language here by its language code. Sphinx will then
translate text that it generates into that language.
For a list of supported codes, see
http://sphinx-doc.org/config.html#confval-language.
> Project language [en]: zh_cn
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]:
One document is special in that it is considered the top node of the
"contents tree", that is, it is the root of the hierarchical structure
of the documents. Normally, this is "index", but if your "index"
document is a custom template, you can also set this to another filename.
> Name of your master document (without suffix) [index]:
Indicate which of the following Sphinx extensions should be enabled:
> autodoc: automatically insert docstrings from modules (y/n) [n]: y
> doctest: automatically test code snippets in doctest blocks (y/n) [n]: y
> intersphinx: link between Sphinx documentation of different projects (y/n) [n]: y
> todo: write "todo" entries that can be shown or hidden on build (y/n) [n]: y
> coverage: checks for documentation coverage (y/n) [n]: y
> imgmath: include math, rendered as PNG or SVG images (y/n) [n]: y
> mathjax: include math, rendered in the browser by MathJax (y/n) [n]: y
> ifconfig: conditional inclusion of content based on config values (y/n) [n]: y
> viewcode: include links to the source code of documented Python objects (y/n) [n]: y
> githubpages: create .nojekyll file to publish the document on GitHub pages (y/n) [n]: y
Note: imgmath and mathjax cannot be enabled at the same time. imgmath has been deselected.
A Makefile and a Windows command file can be generated for you so that you
only have to run e.g. `make html' instead of invoking sphinx-build
directly.
> Create Makefile? (y/n) [y]:
> Create Windows command file? (y/n) [y]: n
Creating file ./source/conf.py.
Creating file ./source/index.rst.
Creating file ./Makefile.
Finished: An initial directory structure has been created.
You should now populate your master file ./source/index.rst and create other documentation
source files. Use the Makefile to build the docs, like so:
make builder
where "builder" is one of the supported builders, e.g. html, latex or linkcheck.
Platform/操作系统类型 macOS
OS version/操作系统版本 10.14.1
Application version/应用程序的版本号 0.5.3
Describe the bug/错误描述 每次编辑较长的代码引用段的时候便会假死一段时间 cpu 100%。 及编辑
代码
中的内容时。我的源文件如下
title: 利用Sphinx创建Python文档 date: 2018-11-06 comments: true categories:
Python
基础资料
我将用如下代码生成文档 run.py
stop.py
安装
当前目录为demo,包含
run.py
和stop.py
两个文件。创建虚拟环境并进入
安装 Sphinx
使用
Sphinx提供默认的快速配置方案,通过命令行交互即可完成全部的配置 我的配置方案如下
配置完后,会形成如下目录结构
修改
source/conf.py
,增加如下内容(或者修改该文件的 15~17行)该配置规定了源文件的路径,我的Sphinx配置在所有源文件的第二层,所以源文件的路径是
../
。执行生成api文档的操作
其中
-o
参数为输出的文档配置的路径,这个需要和Sphinx的配置文件路径路径保持一致;最后一个参数为源文件的根目录。执行
make html
生成文档通过浏览器打开
build/html/index.html
既为我们的文档界面。浏览
默认的文档不是那么美观。我们改用
sphinx_rtd_theme
主题修改
source/conf.py
中的html_theme = 'alabaster'
为html_theme = 'sphinx_rtd_theme'
重新执行
make html
,生成新的配置文件。