summaryrefslogtreecommitdiffstats
path: root/doc/man/sphinx-build.rst
blob: 8be2780d307c62632b4db8c456c93196c87ca829 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
sphinx-build
============

Synopsis
--------

**sphinx-build** [*options*] <*sourcedir*> <*outputdir*> [*filenames* ...]

Description
-----------

:program:`sphinx-build` generates documentation from the files in
``<sourcedir>`` and places it in the ``<outputdir>``.

:program:`sphinx-build` looks for ``<sourcedir>/conf.py`` for the configuration
settings.  :manpage:`sphinx-quickstart(1)` may be used to generate template
files, including ``conf.py``.

:program:`sphinx-build` can create documentation in different formats.  A
format is selected by specifying the builder name on the command line; it
defaults to HTML.  Builders can also perform other tasks related to
documentation processing.  For a list of available builders, refer to
:doc:`/usage/builders/index`.

By default, everything that is outdated is built.  Output only for selected
files can be built by specifying individual filenames.

Options
-------

.. program:: sphinx-build

.. _make_mode:

.. option:: -M buildername

   Select a builder, using the *make-mode*.
   See :doc:`/usage/builders/index` for a list of all of Sphinx's built-in builders.
   Extensions can add their own builders.

   .. important::
      Sphinx only recognizes the ``-M`` option if it is used first, along with
      the source and output directories, before any other options are passed.
      For example::

          sphinx-build -M html ./source ./build -W --keep-going

   The *make-mode* provides the same build functionality as
   a default :ref:`Makefile or Make.bat <makefile_options>`,
   and provides the following additional build pipelines:

   *latexpdf*
     Build LaTeX files and run them through :program:`pdflatex`, or as per
     :confval:`latex_engine` setting.
     If :confval:`language` is set to ``'ja'``, will use automatically
     the :program:`platex/dvipdfmx` latex to PDF pipeline.

   *info*
     Build Texinfo files and run them through :program:`makeinfo`.

   .. note::

      The default output directory locations when using *make-mode*
      differ from the defaults when using :option:`-b`.

      * doctrees are saved to ``<outputdir>/doctrees``
      * output files are saved to ``<outputdir>/<builder name>``

   .. versionadded:: 1.2.1

.. option:: -b buildername, --builder buildername

   Selects a builder.

   See :doc:`/usage/builders/index` for a list of all of Sphinx's built-in builders.
   Extensions can add their own builders.

   .. versionchanged:: 7.3
      Add ``--builder`` long option.

.. option:: -a, --write-all

   If given, always write all output files. The default is to only write output
   files for new and changed source files. (This may not apply to all
   builders.)

   .. note:: This option does not re-read source files.
             To read and re-process every file,
             use :option:`--fresh-env` instead.

   .. versionchanged:: 7.3
      Add ``--write-all`` long option.

.. option:: -E, --fresh-env

   Don't use a saved :term:`environment` (the structure caching all
   cross-references), but rebuild it completely.  The default is to only read
   and parse source files that are new or have changed since the last run.

   .. versionchanged:: 7.3
      Add ``--fresh-env`` long option.

.. option:: -t tag, --tag tag

   Define the tag *tag*.  This is relevant for :rst:dir:`only` directives that
   only include their content if this tag is set.

   .. versionadded:: 0.6

   .. versionchanged:: 7.3
      Add ``--tag`` long option.

.. option:: -d path, --doctree-dir path

   Since Sphinx has to read and parse all source files before it can write an
   output file, the parsed source files are cached as "doctree pickles".
   Normally, these files are put in a directory called :file:`.doctrees` under
   the build directory; with this option you can select a different cache
   directory (the doctrees can be shared between all builders).

   .. versionchanged:: 7.3
      Add ``--doctree-dir`` long option.

.. option:: -j N, --jobs N

   Distribute the build over *N* processes in parallel, to make building on
   multiprocessor machines more effective.  Note that not all parts and not all
   builders of Sphinx can be parallelized.  If ``auto`` argument is given,
   Sphinx uses the number of CPUs as *N*.

   .. versionadded:: 1.2
      This option should be considered *experimental*.

   .. versionchanged:: 1.7
      Support ``auto`` argument.

   .. versionchanged:: 6.2
      Add ``--jobs`` long option.

.. option:: -c path, --config-dir path

   Don't look for the :file:`conf.py` in the source directory, but use the given
   configuration directory instead.  Note that various other files and paths
   given by configuration values are expected to be relative to the
   configuration directory, so they will have to be present at this location
   too.

   .. versionadded:: 0.3

   .. versionchanged:: 7.3
      Add ``--config-dir`` long option.

.. option:: -C, --isolated

   Don't look for a configuration file; only take options via the :option:`--define` option.

   .. versionadded:: 0.5

   .. versionchanged:: 7.3
      Add ``--isolated`` long option.

.. option:: -D setting=value, --define setting=value

   Override a configuration value set in the :file:`conf.py` file.  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.

   .. versionchanged:: 0.6
      The value can now be a dictionary value.

   .. versionchanged:: 1.3
      The value can now also be a list value.

   .. versionchanged:: 7.3
      Add ``--define`` long option.

.. option:: -A name=value, --html-define name=value

   Make the *name* assigned to *value* in the HTML templates.

   .. versionadded:: 0.5

   .. versionchanged:: 7.3
      Add ``--html-define`` long option.

.. option:: -n, --nitpicky

   Run in nit-picky mode.  Currently, this generates warnings for all missing
   references.  See the config value :confval:`nitpick_ignore` for a way to
   exclude some references as "known missing".

   .. versionchanged:: 7.3
      Add ``--nitpicky`` long option.

.. option:: -N, --no-color

   Do not emit colored output.

   .. versionchanged:: 1.6
      Add ``--no-color`` long option.

.. option:: --color

   Emit colored output. Auto-detected by default.

   .. versionadded:: 1.6

.. option:: -v, --verbose

   Increase verbosity (log-level).  This option can be given up to three times
   to get more debug logging output.  It implies :option:`-T`.

   .. versionadded:: 1.2

   .. versionchanged:: 7.3
      Add ``--verbose`` long option.

.. option:: -q, --quiet

   Do not output anything on standard output, only write warnings and errors to
   standard error.

   .. versionchanged:: 7.3
      Add ``--quiet`` long option.

.. option:: -Q, --silent

   Do not output anything on standard output, also suppress warnings.  Only
   errors are written to standard error.

   .. versionchanged:: 7.3
      Add ``--silent`` long option.

.. option:: -w file, --warning-file file

   Write warnings (and errors) to the given file, in addition to standard error.

   .. versionchanged:: 7.3

      ANSI control sequences are stripped when writing to *file*.

   .. versionchanged:: 7.3
      Add ``--warning-file`` long option.

.. option:: -W, --fail-on-warning

   Turn warnings into errors.  This means that the build stops at the first
   warning and ``sphinx-build`` exits with exit status 1.

   .. versionchanged:: 7.3
      Add ``--fail-on-warning`` long option.

.. option:: --keep-going

   With -W option, keep going processing when getting warnings to the end
   of build, and ``sphinx-build`` exits with exit status 1.

   .. versionadded:: 1.8

.. option:: -T, --show-traceback

   Display the full traceback when an unhandled exception occurs.  Otherwise,
   only a summary is displayed and the traceback information is saved to a file
   for further analysis.

   .. versionadded:: 1.2

   .. versionchanged:: 7.3
      Add ``--show-traceback`` long option.

.. option:: -P, --pdb

   (Useful for debugging only.)  Run the Python debugger, :mod:`pdb`, if an
   unhandled exception occurs while building.

   .. versionchanged:: 7.3
      Add ``--pdb`` long option.

.. option:: -h, --help, --version

   Display usage summary or Sphinx version.

   .. versionadded:: 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 these output files
(and their dependencies).

Environment Variables
---------------------

The :program:`sphinx-build` refers following environment variables:

.. describe:: MAKE

   A path to make command.  A command name is also allowed.
   :program:`sphinx-build` uses it to invoke sub-build process on make-mode.

.. _makefile_options:

.. rubric:: Makefile Options

The :file:`Makefile` and :file:`make.bat` files created by
:program:`sphinx-quickstart` usually run :program:`sphinx-build` only with the
:option:`-b` and :option:`-d` options.  However, they support the following
variables to customize behavior:

.. describe:: PAPER

   This sets the ``'papersize'`` key of :confval:`latex_elements`:
   i.e. ``PAPER=a4`` sets it to ``'a4paper'`` and ``PAPER=letter`` to
   ``'letterpaper'``.

   .. note::

      Usage of this environment variable got broken at Sphinx 1.5 as
      ``a4`` or ``letter`` ended up as option to LaTeX document in
      place of the needed ``a4paper``, resp. ``letterpaper``.  Fixed at
      1.7.7.

.. describe:: SPHINXBUILD

   The command to use instead of ``sphinx-build``.

.. describe:: BUILDDIR

   The build directory to use instead of the one chosen in
   :program:`sphinx-quickstart`.

.. describe:: SPHINXOPTS

   Additional options for :program:`sphinx-build`. These options can
   also be set via the shortcut variable **O** (capital 'o').

.. describe:: NO_COLOR

   When set (regardless of value), :program:`sphinx-build`  will not use color
   in terminal output. ``NO_COLOR`` takes precedence over ``FORCE_COLOR``. See
   `no-color.org <https://no-color.org/>`__ for other libraries supporting this
   community standard.

   .. versionadded:: 4.5.0

.. describe:: FORCE_COLOR

   When set (regardless of value), :program:`sphinx-build` will use color in
   terminal output. ``NO_COLOR`` takes precedence over ``FORCE_COLOR``.

   .. versionadded:: 4.5.0

.. _when-deprecation-warnings-are-displayed:

Deprecation Warnings
--------------------

If any deprecation warning like ``RemovedInSphinxXXXWarning`` are displayed
when building a user's document, some Sphinx extension is using deprecated
features. In that case, please report it to author of the extension.

To disable the deprecation warnings, please set ``PYTHONWARNINGS=`` environment
variable to your environment. For example:

* ``PYTHONWARNINGS= make html`` (Linux/Mac)
* ``export PYTHONWARNINGS=`` and do ``make html`` (Linux/Mac)
* ``set PYTHONWARNINGS=`` and do ``make html`` (Windows)
* modify your Makefile/make.bat and set the environment variable

See also
--------

:manpage:`sphinx-quickstart(1)`