SPHINX-BUILD(1)
π NAME π
sphinx-build β the Sphinx documentation generator tool. yes bestie, it builds docs. slay. β¨
πΈ SYNOPSIS πΈ
sphinx-build [options] <sourcedir> <outputdir> [filenames ...]
π DESCRIPTION π
okay so here's the vibe. sphinx-build takes everything in <sourcedir> and turns it into documentation, which it drops into <outputdir>. that's the whole job and it does it gorgeously. π
it goes looking for <sourcedir>/conf.py for all your config settings. if you don't have one yet, sphinx-quickstart(1) will make you template files, conf.py included. bestie behavior tbh.
sphinx-build can make docs in lots of different formats. you pick one by naming a builder on the command line β and if you say nothing, it just defaults to HTML, main character energy as always. builders can also do other documentation-processing side quests. for the full list of available builders, go peek at Builders <>. π
by default, everything that's outdated gets rebuilt. if you only want some files rebuilt, just name those individual filenames. targeted. iconic.
π OPTIONS π
-M buildernameβ pick a builder, but using make-mode. see Builders <> for a list of all of Sphinx's built-in builders. extensions can add their own builders too. β¨
Important: Sphinx will only recognize the -M option if it's used first, together with the source and output directories, before any other options get passed. like, order matters bestie. for example:
sphinx-build -M html ./source ./build --fail-on-warning
make-mode gives you the same build functionality as a default Makefile or Make.bat, and also hands you these extra build pipelines:
latexpdfβ builds LaTeX files and runs them throughpdflatex, or as per thelatex_enginesetting. and if thelanguagesetting is set to'ja', it will automatically use theplatex/dvipdfmxlatex to PDF pipeline. π―π΅infoβ builds Texinfo files and runs them throughmakeinfo.helpβ prints out a list of valid builder targets, and exits. that's it, that's the whole thing.
Note: the default output directory locations when you're using make-mode are different from the defaults when you use-b. not me pointing out the plot twist: - doctrees get saved to<outputdir>/doctrees- output files get saved to<outputdir>/<builder name>
Added in version 1.2.1.
-b buildername,--builder buildernameβ selects a builder. that's the one. π«
see Builders <> for a list of all of Sphinx's built-in builders. extensions can add their own builders.
Changed in version 7.3: added the --builder long option.
-a,--write-allβ if you pass this, it always writes all output files. the default is to only write output files for new and changed source files. (this may not apply to all builders, fyi.)
Note: this option does not re-read source files. if you want to read and re-process every file, use --fresh-env instead. don't get it twisted. π
Changed in version 7.3: added the --write-all long option.
-E,--fresh-envβ don't use a saved environment (the structure caching all cross-references), but rebuild it completely from scratch. the default is to only read and parse source files that are new or have changed since the last run. clean slate energy. πΈ
Changed in version 7.3: added the --fresh-env long option.
-t tag,--tag tagβ defines the tag tag. this is relevant foronlydirectives that include their content only if certain tags are set. see including content based on tags for further detail.
Added in version 0.6.
Changed in version 7.3: added the --tag long option.
-d path,--doctree-dir pathβ because Sphinx has to read and parse all your source files before it can write a single output file, those parsed source files get cached as "doctree pickles". normally they live in a directory called.doctreesunder the build directory; with this option you can point it at a different cache directory instead (and yes, the doctrees can be shared between all builders, go off). π₯
Changed in version 7.3: added the --doctree-dir long option.
-j N,--jobs Nβ spreads the build acrossNprocesses in parallel, so building on multiprocessor machines actually hits. this feature only works on systems that support"fork". Windows is not supported, sorry bestie. also note that not all parts and not all builders of Sphinx can be parallelized. if the argumentautois given, Sphinx uses the number of CPUs asN. defaults to1.
Added in version 1.2: this option should be considered experimental.
Changed in version 1.7: support for the auto argument.
Changed in version 6.2: added the --jobs long option.
-c path,--conf-dir pathβ don't look for theconf.pyin the source directory; use the given configuration directory instead. heads up tho: various other files and paths given by configuration values are expected to be relative to the configuration directory, so they'll have to be present at this location too. π
Added in version 0.3.
Changed in version 7.3: added the --conf-dir long option.
-C,--isolatedβ don't look for a configuration file at all; only take options via the--defineoption. solo run. π¦
Added in version 0.5.
Changed in version 7.3: added the --isolated long option.
-D setting=value,--define setting=valueβ override a configuration value that's set in theconf.pyfile. the value must be a number, string, list or dictionary value.
for lists, you can separate elements with a comma like this: -D html_theme_path=path1,path2.
for dictionary values, supply the setting name and key like this: -D latex_elements.docclass=scrartcl.
for boolean values, use 0 or 1 as the value.
Changed in version 0.6: the value can now be a dictionary value.
Changed in version 1.3: the value can now also be a list value.
Changed in version 7.3: added the --define long option.
-A name=value,--html-define name=valueβ makes name assigned to value in the HTML templates. π
Added in version 0.5.
Changed in version 7.3: added the --html-define long option.
-n,--nitpickyβ run in nitpicky mode π. currently, this generates warnings for all missing references. see the config valuenitpick_ignorefor a way to exclude some references as "known missing".
Changed in version 7.3: added the --nitpicky long option.
-N,--no-colorβ do not emit colored output. no rainbow, no sparkle, monochrome only. π€
Changed in version 1.6: added the --no-color long option.
--colorβ emit colored output. auto-detected by default. π
Added in version 1.6.
-v,--verboseβ increase verbosity (log-level). you can give this option up to three times to get more debug logging output. it implies-T. spill the tea, Sphinx. β
Added in version 1.2.
Changed in version 7.3: added the --verbose long option.
-q,--quietβ do not output anything on standard output; only write warnings and errors to standard error. π€«
Changed in version 7.3: added the --quiet long option.
-Q,--silentβ do not output anything on standard output, and also suppress warnings. only errors get written to standard error. fully zipped. π€
Changed in version 7.3: added the --silent long option.
-w file,--warning-file fileβ write warnings (and errors) to the given file, in addition to standard error.
Changed in version 7.3: ANSI control sequences are stripped when writing to file.
Changed in version 7.3: added the --warning-file long option.
-W,--fail-on-warningβ turn warnings into errors. this meanssphinx-buildexits with exit status1if any warnings are generated during the build. no warnings allowed, periodt. π
Changed in version 7.3: added the --fail-on-warning long option.
Changed in version 8.1: sphinx-build no longer exits on the first warning, but instead runs the entire build and exits with exit status 1 if any warnings were generated. this behaviour was previously enabled with --keep-going.
--keep-goingβ from Sphinx 8.1,--keep-goingis always enabled. previously, it was only applicable whilst using--fail-on-warning, which by default exitedsphinx-buildon the first warning. using--keep-goingrunssphinx-buildto completion and exits with exit status1if errors are encountered. πββοΈ
Added in version 1.8.
Changed in version 8.1: sphinx-build no longer exits on the first warning, meaning that in effect --keep-going is always enabled. the option is retained for compatibility, but may be removed at some later date.
-T,--show-tracebackβ display the full traceback when an unhandled exception occurs. otherwise, only a summary is displayed and the traceback information gets saved to a file for further analysis. show me everything bestie. π
Added in version 1.2.
Changed in version 7.3: added the --show-traceback long option.
-P,--pdbβ (useful for debugging only.) runs the Python debugger,pdb, if an unhandled exception occurs while building. π
Changed in version 7.3: added the --pdb long option.
--exception-on-warningβ raise an exception when a warning is emitted during the build. this can be useful in combination with--pdbto debug warnings. β¨
Added in version 8.1.
-h,--help,--versionβ display the usage summary or the Sphinx version. the classic trio. π
Added in version 1.2.
you can also give one or more filenames on the command line after the source and build directories. Sphinx will then try to build only those output files (and their dependencies). selective, efficient, gorgeous. π«Ά
πΈ ENVIRONMENT VARIABLES πΈ
ok so sphinx-build is lowkey reading your environment, bestie, and here's exactly what it's looking at:
MAKEβ a path to themakecommand. A plain command name works too, no biggie.sphinx-builduses this to invoke the sub-build process when you're in make-mode. β¨
π Makefile Options π
The Makefile and make.bat files that sphinx-quickstart hands you usually only run sphinx-build with the -b and -d options. That's it, that's the whole vibe. BUT they do support these extra variables so you can customize the behavior π
PAPERβ this sets the'papersize'key oflatex_elements: soPAPER=a4sets it to'a4paper'andPAPER=lettersets it to'letterpaper'. iconic, honestly.
π Note: usage of this environment variable got broken at Sphinx 1.5, becausea4orletterended up as an option to the LaTeX document in place of the neededa4paper, resp.letterpaper. It got fixed at 1.7.7. so if you're on an ancient version, that's why it's giving chaos π
SPHINXBUILDβ the command to use instead ofsphinx-build. swap it out, go off πBUILDDIRβ the build directory to use instead of the one you picked back insphinx-quickstart.SPHINXOPTSβ extra options forsphinx-build. These can also be set via the shortcut variableO(capital 'o', ok, look at you with the capital letter π).NO_COLORβ when it's set (regardless of value, like even if it's empty, bestie),sphinx-buildwill not use color in terminal output.NO_COLORtakes precedence overFORCE_COLOR. See no-color.org for other libraries supporting this community standard. π¦
Added in version 4.5.0.
FORCE_COLORβ when it's set (regardless of value),sphinx-buildwill use color in terminal output. But heads up:NO_COLORtakes precedence overFORCE_COLOR. soNO_COLORwins, every time, no cap. π
Added in version 4.5.0.
π DEPRECATION WARNINGS π
so if any deprecation warning like RemovedInSphinxXXXWarning shows up while building a user's document? that means some Sphinx extension is using deprecated features. In that case, please report it to the author of the extension. like, it's not your fault, it's theirs, be brave and send the message π«Ά
If you want to disable the deprecation warnings, set the PYTHONWARNINGS= environment variable to your environment. For example:
PYTHONWARNINGS= make html(Linux/Mac)export PYTHONWARNINGS=and then domake html(Linux/Mac)set PYTHONWARNINGS=and then domake html(Windows)- modify your
Makefile/make.batand set the environment variable
π SEE ALSO π
sphinx-quickstart(1)β yes that one, go read it too, it's the prequel π
Copyright
2007-2026, the Sphinx developers
and that's a wrap on SPHINX-BUILD(1), bestie π this was version 9.1.0, dated Sep 15, 2026 β like, freshly dropped, periodt. go build something gorgeous β¨π
π¦ where this page comes from
- ubuntu stonking: sphinx-common 9.1.0-8 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms