Builders¶
These are the built-in Sphinx builders. More builders can be added by extensions.
The builder's "name" must be given to the -M or -b command-line options of sphinx-build to select a builder.
The most common builders are:
- html
Build HTML pages. This is the default builder.
- dirhtml
Build HTML pages, but with a single directory per document. Makes for prettier URLs (no
.html) if served from a webserver.- singlehtml
Build a single HTML with the whole content.
- htmlhelp, qthelp, devhelp, epub
Build HTML files with additional information for building a documentation collection in one of these formats.
- applehelp
Build an Apple Help Book. Requires hiutil and codesign, which are not Open Source and presently only available on Mac OS X 10.6 and higher.
- latex
Build LaTeX sources that can be compiled to a PDF document using pdflatex.
- man
Build manual pages in groff format for UNIX systems.
- texinfo
Build Texinfo files that can be processed into Info files using makeinfo.
- text
Build plain text files.
- gettext
Build gettext-style message catalogs (
.potfiles).- doctest
Run all doctests in the documentation, if the
doctestextension is enabled.- linkcheck
Check the integrity of all external links.
- xml
Build Docutils-native XML files.
- pseudoxml
Build compact pretty-printed "pseudo-XML" files displaying the internal structure of the intermediate document trees.
- class sphinx.builders.html.StandaloneHTMLBuilder[source]¶
This is the standard HTML builder. Its output is a directory with HTML files, complete with style sheets and optionally the reStructuredText sources. There are quite a few configuration values that customize the output of this builder, see the chapter Options for HTML output for details.
- name: str = 'html'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'html'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- class sphinx.builders.dirhtml.DirectoryHTMLBuilder[source]¶
This is a subclass of the standard HTML builder. Its output is a directory with HTML files, where each file is called
index.htmland placed in a subdirectory named like its page name. For example, the documentmarkup/rest.rstwill not result in an output filemarkup/rest.html, butmarkup/rest/index.html. When generating links between pages, theindex.htmlis omitted, so that the URL would look likemarkup/rest/.- name: str = 'dirhtml'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'html'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg']¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Added in version 0.6.
- class sphinx.builders.singlehtml.SingleFileHTMLBuilder[source]¶
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 root document. No indices will be generated.
- name: str = 'singlehtml'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'html'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg']¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Added in version 1.0.
- class sphinxcontrib.htmlhelp.HTMLHelpBuilder[source]¶
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: str = 'htmlhelp'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'html'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- class sphinxcontrib.qthelp.QtHelpBuilder[source]¶
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.
Changed in version 2.0: Moved to sphinxcontrib.qthelp from sphinx.builders package.
- name: str = 'qthelp'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'html'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- class sphinxcontrib.applehelp.AppleHelpBuilder[source]¶
This builder produces an Apple Help Book based on the same output as the standalone HTML builder.
If the source directory contains any
.lprojfolders, 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_toolstoTrue, in which case the output will not be valid until hiutil has been run on all of the.lprojfolders within the bundle.- name: str = 'applehelp'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'html'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = ['image/png', 'image/gif', 'image/jpeg', 'image/tiff', 'image/jp2', 'image/svg+xml']¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Added in version 1.3.
Changed in version 2.0: Moved to sphinxcontrib.applehelp from sphinx.builders package.
- class sphinxcontrib.devhelp.DevhelpBuilder[source]¶
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: str = 'devhelp'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'html'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = ['image/png', 'image/gif', 'image/jpeg']¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Changed in version 2.0: Moved to sphinxcontrib.devhelp from sphinx.builders package.
- class sphinx.builders.epub3.Epub3Builder[source]¶
This builder produces the same output as the standalone HTML builder, but also generates an epub file for ebook readers. See Epub info for details about it. For definition of the epub format, have a look at https://idpf.org/epub or https://en.wikipedia.org/wiki/EPUB. The builder creates EPUB 3 files.
- name: str = 'epub'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'html'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg']¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Added in version 1.4.
Changed in version 1.5: Since Sphinx 1.5, the epub3 builder is used as the default epub builder.
- class sphinx.builders.latex.LaTeXBuilder[source]¶
This builder produces LaTeX source files in the output directory. The actual PDF builds happen inside this output directory and need to be triggered in a second step. This can be done via make all-pdf there. To combine the two steps into only one, use
sphinx-build -M(i.e.-M latexpdfnot-b latexpdf) or make latexpdf at the project root.See
latex_documentsand the chapter Options for LaTeX output for available options.PDF builds need a sufficiently complete LaTeX installation. The testing is currently (since 5.3.0) done on Ubuntu 22.04LTS, whose LaTeX distribution matches upstream TeXLive 2021 as of 2022/02/04, but PDF builds can be successfully done on much older LaTeX installations.
At any rate, on Ubuntu for example, following packages must all be present:
texlive-latex-recommendedtexlive-fonts-recommendedtexlive-fonts-extra(needed forfontawesome5, see the 7.4.0 change notice below)tex-gyre(iflatex_engineleft to default)texlive-latex-extralatexmk
Changed in version 4.0.0: TeX Gyre fonts now required for
'pdflatex'engine (default).Changed in version 7.4.0: LaTeX package
xcoloris now required (it is part of Ubuntutexlive-latex-recommendedanyhow). The LaTeX packagefontawesome5is recommended. See the 'sphinxsetup'iconpackagekey for more.Additional packages are needed in some circumstances:
texlive-lang-cyrillicfor Cyrillic (and also thencm-superif using the default fonts),texlive-lang-greekfor Greek (and also thencm-superif using the default fonts),texlive-xetexiflatex_engineis'xelatex',texlive-luatexiflatex_engineis'lualatex',fonts-freefont-otfiflatex_engineis either'xelatex'or'lualatex'.
Note
Since 1.6,
make latexpdfuses on GNU/Linux and macOS latexmk, as it makes sure the needed number of runs is automatically executed. On Windows the PDF builds execute a fix number of LaTeX runs (three, thenmakeindex, then two more).One can pass to
latexmkoptions via theLATEXMKOPTSMakefile variable. For example:make latexpdf LATEXMKOPTS="-silent"reduces console output to a minimum.
Also, if
latexmkis 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)latexbinary, use variableLATEXOPTS, for example:make latexpdf LATEXOPTS="--halt-on-error"- name: str = 'latex'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'latex'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
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[source]¶
This builder produces a text file for each reStructuredText file. This is almost the same as the reStructuredText source, but with much of the markup stripped for better readability.
- name: str = 'text'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'text'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = []¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Added in version 0.4.
- class sphinx.builders.manpage.ManualPageBuilder[source]¶
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_pagesconfiguration value.- name: str = 'man'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'man'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = []¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Added in version 1.0.
- class sphinx.builders.texinfo.TexinfoBuilder[source]¶
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_documentsconfiguration 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 info 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: str = 'texinfo'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'texinfo'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = ['image/png', 'image/jpeg', 'image/gif']¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Added in version 1.1.
- class sphinxcontrib.serializinghtml.SerializingHTMLBuilder[source]¶
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()andloads()functions that conform to the functions with the same names from the pickle module. Known modules implementing this interface aresimplejson,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 Serialization builder details for details about the output format.
Added in version 0.5.
- class sphinxcontrib.serializinghtml.PickleHTMLBuilder[source]¶
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 Serialization builder details for details about the output format.
- name: str = 'pickle'¶
The builder's name. This is the value used to select builders on the command line.
The old name
webstill works as well.
- format: str = 'html'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg']¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
The file suffix is
.fpickle. The global context is calledglobalcontext.pickle, the search indexsearchindex.pickle.
- class sphinxcontrib.serializinghtml.JSONHTMLBuilder[source]¶
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 Serialization builder details for details about the output format.
- name: str = 'json'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'html'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = ['image/svg+xml', 'image/png', 'image/gif', 'image/jpeg']¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
The file suffix is
.fjson. The global context is calledglobalcontext.json, the search indexsearchindex.json.Added in version 0.5.
- class sphinx.builders.gettext.MessageCatalogBuilder[source]¶
This builder produces gettext-style message catalogs. Each top-level file or subdirectory grows a single
.potcatalog template.See the documentation on 国际化 for further reference.
- name: str = 'gettext'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = ''¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = []¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Added in version 1.1.
- class sphinx.builders.changes.ChangesBuilder[source]¶
This builder produces an HTML overview of all
versionadded,versionchanged,deprecatedandversionremoveddirectives for the currentversion. This is useful to generate a changelog file, for example.- name: str = 'changes'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = ''¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- class sphinx.builders.dummy.DummyBuilder[source]¶
This builder produces no output. The input is only parsed and checked for consistency. This is useful for linting purposes.
- name: str = 'dummy'¶
The builder's name. This is the value used to select builders on the command line.
- supported_image_types: list[str] = []¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Added in version 1.4.
- class sphinx.builders.linkcheck.CheckExternalLinksBuilder[source]¶
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.txtin the output directory.- name: str = 'linkcheck'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = ''¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = []¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Changed in version 1.5: Since Sphinx 1.5, the linkcheck builder uses the requests module.
Changed in version 3.4: The linkcheck builder retries links when servers apply rate limits.
- class sphinx.builders.xml.XMLBuilder[source]¶
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: str = 'xml'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'xml'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = []¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Added in version 1.2.
- class sphinx.builders.xml.PseudoXMLBuilder[source]¶
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: str = 'pseudoxml'¶
The builder's name. This is the value used to select builders on the command line.
- format: str = 'pseudoxml'¶
The builder's output format, or '' if no document output is produced. This is commonly the file extension, e.g. "html", though any string value is accepted. The builder's format string can be used by various components such as
SphinxPostTransformor extensions to determine their compatibility with the builder.
- supported_image_types: list[str] = []¶
The list of MIME types of image formats supported by the builder. Image files are searched in the order in which they appear here.
Added in version 1.2.
Built-in Sphinx extensions that offer more builders are:
Serialization builder details¶
All serialization builders outputs one file per source file and a few special
files. They also copy the reStructuredText source files
to the _sources directory 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:
bodyThe HTML "body" (that is, the HTML rendering of the source file), as rendered by the HTML translator.
titleThe title of the document, as HTML (may contain markup).
tocThe table of contents for the file, rendered as an HTML
<ul>.display_tocA boolean that is
Trueif thetoccontains more than one entry.current_page_nameThe document name of the current file.
parents,prevandnextInformation 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).parentsis a list of relations, whileprevandnextare a single relation.sourcenameThe name of the source file under
_sources.
The special files are located in the root output directory. They are:
SerializingHTMLBuilder.globalcontext_filenameA pickled dict with these keys:
project,copyright,release,versionThe same values as given in the configuration file.
stylelast_updatedDate of last build.
builderName of the used builder, in the case of pickles this is always
'pickle'.titlesA dictionary of all documents' titles, as HTML strings.
SerializingHTMLBuilder.searchindex_filenameAn 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.pickleThe 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.
Todo
Document common members.
Unlike the other pickle files this pickle file requires that the
sphinxpackage is available on unpickling.