构建器¶
These are the built-in Sphinx builders. More builders can be added by extensions.
The builder’s “name” must be given to the -b command-line option of sphinx-build to select a builder.
-
class
sphinx.builders.html.
StandaloneHTMLBuilder
[源代码]¶ This is the standard HTML builder. Its output is a directory with HTML files, complete with style sheets and optionally the reST sources. There are quite a few configuration values that customize the output of this builder, see the chapter HTML输出选项 for details.
-
name
= 'html'¶
-
format
= 'html'¶
-
supported_image_types
= ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg']¶
-
-
class
sphinx.builders.dirhtml.
DirectoryHTMLBuilder
[源代码]¶ This is a subclass of the standard HTML builder. Its output is a directory with HTML files, where each file is called
index.html
and placed in a subdirectory named like its page name. For example, the documentmarkup/rest.rst
will not result in an output filemarkup/rest.html
, butmarkup/rest/index.html
. When generating links between pages, theindex.html
is omitted, so that the URL would look likemarkup/rest/
.-
name
= 'dirhtml'¶
-
format
= 'html'¶
-
supported_image_types
= ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg']¶
0.6 新版功能.
-
-
class
sphinx.builders.singlehtml.
SingleFileHTMLBuilder
[源代码]¶ This is an HTML builder that combines the whole project in one output file. (Obviously this only works with smaller projects.) The file is named like the master document. No indices will be generated.
-
name
= 'singlehtml'¶
-
format
= 'html'¶
-
supported_image_types
= ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg']¶
1.0 新版功能.
-
-
class
sphinx.builders.htmlhelp.
HTMLHelpBuilder
[源代码]¶ This builder produces the same output as the standalone HTML builder, but also generates HTML Help support files that allow the Microsoft HTML Help Workshop to compile them into a CHM file.
-
name
= 'htmlhelp'¶
-
format
= 'html'¶
-
supported_image_types
= ['image/png', 'image/gif', 'image/jpeg']¶
-
-
class
sphinxcontrib.qthelp.
QtHelpBuilder
[源代码]¶ This builder produces the same output as the standalone HTML builder, but also generates Qt help collection support files that allow the Qt collection generator to compile them.
在 2.0 版更改: Moved to sphinxcontrib.qthelp from sphinx.builders package.
-
name
= 'qthelp'¶
-
format
= 'html'¶
-
supported_image_types
= ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg']¶
-
-
class
sphinxcontrib.applehelp.
AppleHelpBuilder
[源代码]¶ This builder produces an Apple Help Book based on the same output as the standalone HTML builder.
If the source directory contains any
.lproj
folders, the one corresponding to the selected language will have its contents merged with the generated output. These folders will be ignored by all other documentation types.In order to generate a valid help book, this builder requires the command line tool hiutil, which is only available on Mac OS X 10.6 and above. You can disable the indexing step by setting
applehelp_disable_external_tools
toTrue
, in which case the output will not be valid until hiutil has been run on all of the.lproj
folders within the bundle.-
name
= 'applehelp'¶
-
format
= 'html'¶
-
supported_image_types
= ['image/png', 'image/gif', 'image/jpeg', 'image/tiff', 'image/jp2', 'image/svg+xml']¶
1.3 新版功能.
在 2.0 版更改: Moved to sphinxcontrib.applehelp from sphinx.builders package.
-
-
class
sphinxcontrib.devhelp.
DevhelpBuilder
[源代码]¶ This builder produces the same output as the standalone HTML builder, but also generates GNOME Devhelp support file that allows the GNOME Devhelp reader to view them.
-
name
= 'devhelp'¶
-
format
= 'html'¶
-
supported_image_types
= ['image/png', 'image/gif', 'image/jpeg']¶
在 2.0 版更改: Moved to sphinxcontrib.devhelp from sphinx.builders package.
-
-
class
sphinx.builders.epub3.
Epub3Builder
[源代码]¶ This builder produces the same output as the standalone HTML builder, but also generates an epub file for ebook readers. See Epub 信息 for details about it. For definition of the epub format, have a look at http://idpf.org/epub or https://en.wikipedia.org/wiki/EPUB. The builder creates EPUB 3 files.
-
name
= 'epub'¶
-
format
= 'html'¶
-
supported_image_types
= ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg']¶
1.4 新版功能.
在 1.5 版更改: Since Sphinx-1.5, the epub3 builder is used for the default builder of epub.
-
-
class
sphinx.builders.latex.
LaTeXBuilder
[源代码]¶ This builder produces a bunch of LaTeX files in the output directory. You have to specify which documents are to be included in which LaTeX files via the
latex_documents
configuration value. There are a few configuration values that customize the output of this builder, see the chapter LaTeX输出的选项 for details.The produced LaTeX file uses several LaTeX packages that may not be present in a “minimal” TeX distribution installation.
On Ubuntu xenial, the following packages need to be installed for successful PDF builds:
texlive-latex-recommended
texlive-fonts-recommended
texlive-latex-extra
latexmk
(this is a Sphinx requirement on GNU/Linux and MacOS X for functioning ofmake latexpdf
)
Additional packages are needed in some circumstances (see the discussion of the
'fontpkg'
key oflatex_elements
for more information):to support occasional Cyrillic letters or words, and a fortiori if
language
is set to a Cyrillic language, the packagetexlive-lang-cyrillic
is required, and, with unmodified'fontpkg'
, alsocm-super
orcm-super-minimal
,to support occasional Greek letters or words (in text, not in
math
directive contents),texlive-lang-greek
is required, and, with unmodified'fontpkg'
, alsocm-super
orcm-super-minimal
,for
'xelatex'
or'lualatex'
(seelatex_engine
),texlive-xetex
resp.texlive-luatex
, and, if leaving unchanged'fontpkg'
,fonts-freefont-otf
.
The testing of Sphinx LaTeX is done on Ubuntu xenial whose TeX distribution is based on a TeXLive 2015 snapshot dated March 2016.
在 1.6 版更改: Formerly, testing had been done on Ubuntu precise (TeXLive 2009).
在 2.0 版更改: Formerly, testing had been done on Ubuntu trusty (TeXLive 2013).
注解
Since 1.6,
make latexpdf
useslatexmk
(not on Windows). This makes sure the needed number of runs is automatically executed to get the cross-references, bookmarks, indices, and tables of contents right.One can pass to
latexmk
options via theLATEXMKOPTS
Makefile variable. For example:make latexpdf LATEXMKOPTS="-silent"
reduces console output to a minimum.
Also, if
latexmk
is at version 4.52b or higher (January 2017)LATEXMKOPTS="-xelatex"
speeds up PDF builds via XeLateX in case of numerous graphics inclusions.To pass options directly to the
(pdf|xe|lua)latex
binary, use variableLATEXOPTS
, for example:make latexpdf LATEXOPTS="--halt-on-error"
-
name
= 'latex'¶
-
format
= 'latex'¶
-
supported_image_types
= ['application/pdf', 'image/png', 'image/jpeg']¶
Note that a direct PDF builder is being provided by rinohtype. The builder’s
name is rinoh
. Refer to the rinohtype manual for details.
-
class
sphinx.builders.text.
TextBuilder
[源代码]¶ This builder produces a text file for each reST file – this is almost the same as the reST source, but with much of the markup stripped for better readability.
-
name
= 'text'¶
-
format
= 'text'¶
-
supported_image_types
= []¶
0.4 新版功能.
-
-
class
sphinx.builders.manpage.
ManualPageBuilder
[源代码]¶ This builder produces manual pages in the groff format. You have to specify which documents are to be included in which manual pages via the
man_pages
configuration value.-
name
= 'man'¶
-
format
= 'man'¶
-
supported_image_types
= []¶
1.0 新版功能.
-
-
class
sphinx.builders.texinfo.
TexinfoBuilder
[源代码]¶ This builder produces Texinfo files that can be processed into Info files by the makeinfo program. You have to specify which documents are to be included in which Texinfo files via the
texinfo_documents
configuration value.The Info format is the basis of the on-line help system used by GNU Emacs and the terminal-based program info. See Texinfo 信息 for more details. The Texinfo format is the official documentation system used by the GNU project. More information on Texinfo can be found at https://www.gnu.org/software/texinfo/.
-
name
= 'texinfo'¶
-
format
= 'texinfo'¶
-
supported_image_types
= ['image/png', 'image/jpeg', 'image/gif']¶
1.1 新版功能.
-
-
class
sphinxcontrib.serializinghtml.
SerializingHTMLBuilder
[源代码]¶ This builder uses a module that implements the Python serialization API (pickle, simplejson, phpserialize, and others) to dump the generated HTML documentation. The pickle builder is a subclass of it.
A concrete subclass of this builder serializing to the PHP serialization format could look like this:
import phpserialize class PHPSerializedBuilder(SerializingHTMLBuilder): name = 'phpserialized' implementation = phpserialize out_suffix = '.file.phpdump' globalcontext_filename = 'globalcontext.phpdump' searchindex_filename = 'searchindex.phpdump'
-
implementation
¶ A module that implements dump(), load(), dumps() and loads() functions that conform to the functions with the same names from the pickle module. Known modules implementing this interface are simplejson, phpserialize, plistlib, and others.
-
out_suffix
¶ The suffix for all regular files.
-
globalcontext_filename
¶ The filename for the file that contains the “global context”. This is a dict with some general configuration values such as the name of the project.
-
searchindex_filename
¶ The filename for the search index Sphinx generates.
See 序列化构建器详细信息 for details about the output format.
0.5 新版功能.
-
-
class
sphinxcontrib.serializinghtml.
PickleHTMLBuilder
[源代码]¶ This builder produces a directory with pickle files containing mostly HTML fragments and TOC information, for use of a web application (or custom postprocessing tool) that doesn’t use the standard HTML templates.
See 序列化构建器详细信息 for details about the output format.
-
name
= 'pickle'¶ The old name
web
still works as well.
-
format
= 'html'¶
-
supported_image_types
= ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg']¶
The file suffix is
.fpickle
. The global context is calledglobalcontext.pickle
, the search indexsearchindex.pickle
.-
-
class
sphinxcontrib.serializinghtml.
JSONHTMLBuilder
[源代码]¶ This builder produces a directory with JSON files containing mostly HTML fragments and TOC information, for use of a web application (or custom postprocessing tool) that doesn’t use the standard HTML templates.
See 序列化构建器详细信息 for details about the output format.
-
name
= 'json'¶
-
format
= 'html'¶
-
supported_image_types
= ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg']¶
The file suffix is
.fjson
. The global context is calledglobalcontext.json
, the search indexsearchindex.json
.0.5 新版功能.
-
-
class
sphinx.builders.gettext.
MessageCatalogBuilder
[源代码]¶ This builder produces gettext-style message catalogs. Each top-level file or subdirectory grows a single
.pot
catalog template.See the documentation on 国际化 for further reference.
-
name
= 'gettext'¶
-
format
= ''¶
-
supported_image_types
= []¶
1.1 新版功能.
-
-
class
sphinx.builders.changes.
ChangesBuilder
[源代码]¶ This builder produces an HTML overview of all
versionadded
,versionchanged
anddeprecated
directives for the currentversion
. This is useful to generate a ChangeLog file, for example.-
name
= 'changes'¶
-
format
= ''¶
-
supported_image_types
= []¶
-
-
class
sphinx.builders.dummy.
DummyBuilder
[源代码]¶ This builder produces no output. The input is only parsed and checked for consistency. This is useful for linting purposes.
-
name
= 'dummy'¶
-
supported_image_types
= []¶
1.4 新版功能.
-
-
class
sphinx.builders.linkcheck.
CheckExternalLinksBuilder
[源代码]¶ This builder scans all documents for external links, tries to open them with
requests
, and writes an overview which ones are broken and redirected to standard output and tooutput.txt
in the output directory.-
name
= 'linkcheck'¶
-
format
= ''¶
-
supported_image_types
= []¶
在 1.5 版更改: Since Sphinx-1.5, the linkcheck builder comes to use requests module.
-
-
class
sphinx.builders.xml.
XMLBuilder
[源代码]¶ This builder produces Docutils-native XML files. The output can be transformed with standard XML tools such as XSLT processors into arbitrary final forms.
-
name
= 'xml'¶
-
format
= 'xml'¶
-
supported_image_types
= []¶
1.2 新版功能.
-
-
class
sphinx.builders.xml.
PseudoXMLBuilder
[源代码]¶ This builder is used for debugging the Sphinx/Docutils “Reader to Transform to Writer” pipeline. It produces compact pretty-printed “pseudo-XML”, files where nesting is indicated by indentation (no end-tags). External attributes for all elements are output, and internal attributes for any leftover “pending” elements are also given.
-
name
= 'pseudoxml'¶
-
format
= 'pseudoxml'¶
-
supported_image_types
= []¶
1.2 新版功能.
-
Built-in Sphinx extensions that offer more builders are:
序列化构建器详细信息¶
All serialization builders outputs one file per source file and a few special
files. They also copy the reST source files in the directory _sources
under the output directory.
The PickleHTMLBuilder
is a builtin subclass that implements the pickle
serialization interface.
The files per source file have the extensions of
out_suffix
, and are arranged in directories
just as the source files are. They unserialize to a dictionary (or dictionary
like structure) with these keys:
body
The HTML “body” (that is, the HTML rendering of the source file), as rendered by the HTML translator.
title
The title of the document, as HTML (may contain markup).
toc
The table of contents for the file, rendered as an HTML
<ul>
.display_toc
A boolean that is
True
if thetoc
contains more than one entry.current_page_name
The document name of the current file.
parents
,prev
andnext
Information about related chapters in the TOC tree. Each relation is a dictionary with the keys
link
(HREF for the relation) andtitle
(title of the related document, as HTML).parents
is a list of relations, whileprev
andnext
are a single relation.sourcename
The name of the source file under
_sources
.
The special files are located in the root output directory. They are:
SerializingHTMLBuilder.globalcontext_filename
A pickled dict with these keys:
project
,copyright
,release
,version
The same values as given in the configuration file.
style
last_updated
Date of last build.
builder
Name of the used builder, in the case of pickles this is always
'pickle'
.titles
A dictionary of all documents’ titles, as HTML strings.
SerializingHTMLBuilder.searchindex_filename
An index that can be used for searching the documentation. It is a pickled list with these entries:
A list of indexed docnames.
A list of document titles, as HTML strings, in the same order as the first list.
A dict mapping word roots (processed by an English-language stemmer) to a list of integers, which are indices into the first list.
environment.pickle
The build environment. This is always a pickle file, independent of the builder and a copy of the environment that was used when the builder was started.
待处理
Document common members.
Unlike the other pickle files this pickle file requires that the
sphinx
package is available on unpickling.