Builders

These are the built-in Sphinx builders. More builders can be added byextensions.

The builder’s “name” must be given to the-M or-b command-line options ofsphinx-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 forprettier 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 documentationcollection in one of these formats.

applehelp

Build an Apple Help Book. Requireshiutil andcodesign, which are not Open Source and presently onlyavailable on Mac OS X 10.6 and higher.

latex

Build LaTeX sources that can be compiled to a PDF document usingpdflatex.

man

Build manual pages in groff format for UNIX systems.

texinfo

Build Texinfo files that can be processed into Info files usingmakeinfo.

text

Build plain text files.

gettext

Build gettext-style message catalogs (.pot files).

doctest

Run all doctests in the documentation, if thedoctestextension 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 theinternal structure of the intermediate document trees.


classsphinx.builders.html.StandaloneHTMLBuilder[source]

This is the standard HTML builder. Its output is a directory with HTMLfiles, complete with style sheets and optionally the reStructuredText sources.There are quite a few configuration values that customizethe output of this builder, see the chapterOptions for HTML output for details.

name='html'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=['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.

classsphinx.builders.dirhtml.DirectoryHTMLBuilder[source]

This is a subclass of the standard HTML builder. Its output is a directorywith HTML files, where each file is calledindex.html and placed in asubdirectory 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'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=['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.

classsphinx.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 likethe root document. No indices will be generated.

name='singlehtml'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=['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.

classsphinxcontrib.htmlhelp.HTMLHelpBuilder[source]

This builder produces the same output as the standalone HTML builder, butalso generates HTML Help support files that allow the Microsoft HTML HelpWorkshop to compile them into a CHM file.

name='htmlhelp'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=['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.

classsphinxcontrib.qthelp.QtHelpBuilder[source]

This builder produces the same output as the standalone HTML builder, butalso generatesQt help collection support files that allow the Qtcollection generator to compile them.

Changed in version 2.0:Moved to sphinxcontrib.qthelp from sphinx.builders package.

name='qthelp'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=['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.

classsphinxcontrib.applehelp.AppleHelpBuilder[source]

This builder produces an Apple Help Book based on the same output as thestandalone HTML builder.

If the source directory contains any.lproj folders, the onecorresponding to the selected language will have its contents merged withthe generated output. These folders will be ignored by all otherdocumentation types.

In order to generate a valid help book, this builder requires the commandline toolhiutil, which is only available on Mac OS X 10.6 andabove. You can disable the indexing step by settingapplehelp_disable_external_tools toTrue, in which case theoutput will not be valid untilhiutil has been run on all of the.lproj folders within the bundle.

name='applehelp'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=['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.

classsphinxcontrib.devhelp.DevhelpBuilder[source]

This builder produces the same output as the standalone HTML builder, butalso generatesGNOME Devhelpsupport file that allows the GNOME Devhelp reader to view them.

name='devhelp'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=['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.

classsphinx.builders.epub3.Epub3Builder[source]

This builder produces the same output as the standalone HTML builder, butalso generates anepub file for ebook readers. SeeEpub info fordetails about it. For definition of the epub format, have a look athttps://idpf.org/epub orhttps://en.wikipedia.org/wiki/EPUB.The builder createsEPUB 3 files.

name='epub'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=['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.

classsphinx.builders.latex.LaTeXBuilder[source]

This builder produces LaTeX source files in the output directory. Theactual PDF builds happen inside this output directory and need to betriggered in a second step. This can be done viamake all-pdf there.To combine the two steps into only one, usesphinx-build-M(i.e.-Mlatexpdf not-blatexpdf) ormake latexpdfat the project root.

Seelatex_documents and the chapterOptions for LaTeX output foravailable 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-recommended

  • texlive-fonts-recommended

  • texlive-fonts-extra (needed forfontawesome5, see the 7.4.0change notice below)

  • tex-gyre (iflatex_engine left to default)

  • texlive-latex-extra

  • latexmk

Changed in version 4.0.0:TeX Gyre fonts now required for'pdflatex' engine (default).

Changed in version 7.4.0:LaTeX packagexcolor is now required (it is part of Ubuntutexlive-latex-recommended anyhow). The LaTeX packagefontawesome5 is recommended. See the‘sphinxsetup’iconpackage key for more.

Additional packages are needed in some circumstances:

  • texlive-lang-cyrillic for Cyrillic (and also thencm-super if using the default fonts),

  • texlive-lang-greek for Greek (and also thencm-super if using the default fonts),

  • texlive-xetex iflatex_engine is'xelatex',

  • texlive-luatex iflatex_engine is'lualatex',

  • fonts-freefont-otf iflatex_engine is either'xelatex' or'lualatex'.

Note

Since 1.6,makelatexpdf uses on GNU/Linux and macOSlatexmk, as itmakes 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 tolatexmk options via theLATEXMKOPTSMakefile variable. For example:

make latexpdf LATEXMKOPTS="-silent"

reduces console output to a minimum.

Also, iflatexmk is at version 4.52b or higher (January 2017)LATEXMKOPTS="-xelatex" speeds up PDF builds via XeLateX in caseof numerous graphics inclusions.

To pass options directly to the(pdf|xe|lua)latex binary, usevariableLATEXOPTS, for example:

make latexpdf LATEXOPTS="--halt-on-error"
name='latex'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=['application/pdf','image/png','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.

Note that a direct PDF builder is being provided byrinohtype. The builder’sname isrinoh. Refer to therinohtype manual for details.

classsphinx.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='text'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=[]

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.

classsphinx.builders.manpage.ManualPageBuilder[source]

This builder produces manual pages in the groff format. You have to specifywhich documents are to be included in which manual pages via theman_pages configuration value.

name='man'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=[]

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.

classsphinx.builders.texinfo.TexinfoBuilder[source]

This builder produces Texinfo files that can be processed into Info files bythemakeinfo program. You have to specify which documents are tobe included in which Texinfo files via thetexinfo_documentsconfiguration value.

The Info format is the basis of the on-line help system used by GNU Emacs andthe terminal-based programinfo. SeeTexinfo info for moredetails. The Texinfo format is the official documentation system used by theGNU project. More information on Texinfo can be found athttps://www.gnu.org/software/texinfo/.

name='texinfo'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=['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.

classsphinxcontrib.serializinghtml.SerializingHTMLBuilder[source]

This builder uses a module that implements the Python serialization API(pickle,simplejson,phpserialize, and others) to dump thegenerated HTML documentation. The pickle builder is a subclass of it.

A concrete subclass of this builder serializing to thePHP serializationformat could look like this:

importphpserializeclassPHPSerializedBuilder(SerializingHTMLBuilder):name='phpserialized'implementation=phpserializeout_suffix='.file.phpdump'globalcontext_filename='globalcontext.phpdump'searchindex_filename='searchindex.phpdump'
implementation

A module that implementsdump(),load(),dumps() andloads()functions that conform to the functions with the same names from thepickle 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”. Thisis a dict with some general configuration values such as the nameof the project.

searchindex_filename

The filename for the search index Sphinx generates.

SeeSerialization builder details for details about the output format.

Added in version 0.5.

classsphinxcontrib.serializinghtml.PickleHTMLBuilder[source]

This builder produces a directory with pickle files containing mostly HTMLfragments and TOC information, for use of a web application (or custompostprocessing tool) that doesn’t use the standard HTML templates.

SeeSerialization builder details for details about the output format.

name='pickle'

The builder’s name.This is the value used to select builders on the command line.

The old nameweb still works as well.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=['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.

classsphinxcontrib.serializinghtml.JSONHTMLBuilder[source]

This builder produces a directory with JSON files containing mostly HTMLfragments and TOC information, for use of a web application (or custompostprocessing tool) that doesn’t use the standard HTML templates.

SeeSerialization builder details for details about the output format.

name='json'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=['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.

classsphinx.builders.gettext.MessageCatalogBuilder[source]

This builder produces gettext-style message catalogs. Each top-level file orsubdirectory grows a single.pot catalog template.

See the documentation onInternationalization for further reference.

name='gettext'

The builder’s name.This is the value used to select builders on the command line.

format=''

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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=[]

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.

classsphinx.builders.changes.ChangesBuilder[source]

This builder produces an HTML overview of allversionadded,versionchanged,deprecated andversionremoveddirectives for the currentversion. This is useful to generate achangelog file, for example.

name='changes'

The builder’s name.This is the value used to select builders on the command line.

format=''

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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=[]

The list of MIME types of image formats supported by the builder.Image files are searched in the order in which they appear here.

classsphinx.builders.dummy.DummyBuilder[source]

This builder produces no output. The input is only parsed and checked forconsistency. This is useful for linting purposes.

name='dummy'

The builder’s name.This is the value used to select builders on the command line.

supported_image_types=[]

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.

classsphinx.builders.linkcheck.CheckExternalLinksBuilder[source]

This builder scans all documents for external links, tries to open them withrequests, and writes an overview which ones are broken and redirected tostandard output and tooutput.txt in the output directory.

name='linkcheck'

The builder’s name.This is the value used to select builders on the command line.

format=''

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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=[]

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.

classsphinx.builders.xml.XMLBuilder[source]

This builder produces Docutils-native XML files. The output can betransformed with standard XML tools such as XSLT processors into arbitraryfinal forms.

name='xml'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=[]

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.

classsphinx.builders.xml.PseudoXMLBuilder[source]

This builder is used for debugging the Sphinx/Docutils “Reader to Transformto Writer” pipeline. It produces compact pretty-printed “pseudo-XML”, fileswhere nesting is indicated by indentation (no end-tags). Externalattributes for all elements are output, and internal attributes for anyleftover “pending” elements are also given.

name='pseudoxml'

The builder’s name.This is the value used to select builders on the command line.

format='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 componentssuch asSphinxPostTransform or extensions to determinetheir compatibility with the builder.

supported_image_types=[]

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 specialfiles. They also copy the reStructuredText source filesto the_sources directory under the output directory.

ThePickleHTMLBuilder is a builtin subclass that implements the pickleserialization interface.

The files per source file have the extensions ofout_suffix, and are arranged in directoriesjust as the source files are. They unserialize to a dictionary (or dictionarylike structure) with these keys:

body

The HTML “body” (that is, the HTML rendering of the source file), as renderedby 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 isTrue 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 adictionary with the keyslink (HREF for the relation) andtitle(title of the related document, as HTML).parents is a list ofrelations, 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

html_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 pickledlist with these entries:

  • A list of indexed docnames.

  • A list of document titles, as HTML strings, in the same order as the firstlist.

  • A dict mapping word roots (processed by an English-language stemmer) to alist of integers, which are indices into the first list.

environment.pickle

The build environment. This is always a pickle file, independent of thebuilder and a copy of the environment that was used when the builder wasstarted.

Unlike the other pickle files this pickle file requires that thesphinxpackage is available on unpickling.

Previous
Configuration
Next
Domains