sphinx-build¶
概要¶
sphinx-build [options] <sourcedir> <outputdir> [filenames ...]
描述¶
sphinx-build generates documentation from the files in
<sourcedir> and places it in the <outputdir>.
sphinx-build looks for <sourcedir>/conf.py for the configuration
settings. sphinx-quickstart(1) may be used to generate template
files, including conf.py.
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 建置器.
By default, everything that is outdated is built. Output only for selected files can be built by specifying individual filenames.
選項¶
- -M buildername¶
Select a builder, using the make-mode. See 建置器 for a list of all of Sphinx's built-in builders. Extensions can add their own builders.
重要
Sphinx only recognizes the
-Moption 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 --fail-on-warning
The make-mode provides the same build functionality as a default Makefile or Make.bat, and provides the following additional build pipelines:
- latexpdf
Build LaTeX files and run them through pdflatex, or as per
latex_enginesetting. Iflanguageis set to'ja', will use automatically the platex/dvipdfmx latex to PDF pipeline.- info
Build Texinfo files and run them through makeinfo.
- help
Output a list of valid builder targets, and exit.
備註
The default output directory locations when using make-mode differ from the defaults when using
-b.doctrees are saved to
<outputdir>/doctreesoutput files are saved to
<outputdir>/<builder name>
在 1.2.1 版被加入.
- -b buildername, --builder buildername¶
Selects a builder.
See 建置器 for a list of all of Sphinx's built-in builders. Extensions can add their own builders.
在 7.3 版的變更: 增添
--builder長選項。
- -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.)
備註
This option does not re-read source files. To read and re-process every file, use
--fresh-envinstead.在 7.3 版的變更: 增添
--write-all長選項。
- -E, --fresh-env¶
Don't use a saved 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.
在 7.3 版的變更: 增添
--fresh-env長選項。
- -t tag, --tag tag¶
Define the tag tag. This is relevant for
onlydirectives that include their content only if certain tags are set. See including content based on tags for further detail.在 0.6 版被加入.
在 7.3 版的變更: 增添
--tag長選項。
- -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
.doctreesunder the build directory; with this option you can select a different cache directory (the doctrees can be shared between all builders).在 7.3 版的變更: 增添
--doctree-dir長選項。
- -j N, --jobs N¶
Distribute the build over N processes in parallel, to make building on multiprocessor machines more effective. This feature only works on systems supporting "fork". Windows is not supported. Note that not all parts and not all builders of Sphinx can be parallelized. If
autoargument is given, Sphinx uses the number of CPUs as N. Defaults to 1.在 1.2 版被加入: This option should be considered experimental.
在 1.7 版的變更: Support
autoargument.在 6.2 版的變更: 增添
--jobs長選項。
- -c path, --conf-dir path¶
Don't look for the
conf.pyin 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.在 0.3 版被加入.
在 7.3 版的變更: 增添
--conf-dir長選項。
- -C, --isolated¶
Don't look for a configuration file; only take options via the
--defineoption.在 0.5 版被加入.
在 7.3 版的變更: 增添
--isolated長選項。
- -D setting=value, --define setting=value¶
Override a configuration value set in the
conf.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
0or1as the value.在 0.6 版的變更: The value can now be a dictionary value.
在 1.3 版的變更: The value can now also be a list value.
在 7.3 版的變更: 增添
--define長選項。
- -A name=value, --html-define name=value¶
Make the name assigned to value in the HTML templates.
在 0.5 版被加入.
在 7.3 版的變更: 增添
--html-define長選項。
- -n, --nitpicky¶
Run in nitpicky mode. Currently, this generates warnings for all missing references. See the config value
nitpick_ignorefor a way to exclude some references as "known missing".在 7.3 版的變更: 增添
--nitpicky長選項。
- -N, --no-color¶
Do not emit colored output.
在 1.6 版的變更: 增添
--no-color長選項。
- --color¶
Emit colored output. Auto-detected by default.
在 1.6 版被加入.
- -v, --verbose¶
Increase verbosity (log-level). This option can be given up to three times to get more debug logging output. It implies
-T.在 1.2 版被加入.
在 7.3 版的變更: 增添
--verbose長選項。
- -q, --quiet¶
Do not output anything on standard output, only write warnings and errors to standard error.
在 7.3 版的變更: 增添
--quiet長選項。
- -Q, --silent¶
Do not output anything on standard output, also suppress warnings. Only errors are written to standard error.
在 7.3 版的變更: 增添
--silent長選項。
- -w file, --warning-file file¶
Write warnings (and errors) to the given file, in addition to standard error.
在 7.3 版的變更: ANSI control sequences are stripped when writing to file.
在 7.3 版的變更: 增添
--warning-file長選項。
- -W, --fail-on-warning¶
Turn warnings into errors. This means that sphinx-build exits with exit status 1 if any warnings are generated during the build.
在 7.3 版的變更: 增添
--fail-on-warning長選項。在 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 exited sphinx-build on the first warning. Using--keep-goingruns sphinx-build to completion and exits with exit status 1 if errors are encountered.在 1.8 版被加入.
在 8.1 版的變更: sphinx-build no longer exits on the first warning, meaning that in effect
--keep-goingis 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 is saved to a file for further analysis.
在 1.2 版被加入.
在 7.3 版的變更: 增添
--show-traceback長選項。
- -P, --pdb¶
(Useful for debugging only.) Run the Python debugger,
pdb, if an unhandled exception occurs while building.在 7.3 版的變更: 增添
--pdb長選項。
- --exception-on-warning¶
Raise an exception when a warning is emitted during the build. This can be useful in combination with
--pdbto debug warnings.在 8.1 版被加入.
- -h, --help, --version¶
Display usage summary or Sphinx 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 these output files (and their dependencies).
環境變數¶
The sphinx-build refers following environment variables:
- MAKE
A path to make command. A command name is also allowed. sphinx-build uses it to invoke sub-build process on make-mode.
Makefile 選項
The Makefile and make.bat files created by
sphinx-quickstart usually run sphinx-build only with the
-b and -d options. However, they support the following
variables to customize behavior:
- PAPER
This sets the
'papersize'key oflatex_elements: i.e.PAPER=a4sets it to'a4paper'andPAPER=letterto'letterpaper'.備註
Usage of this environment variable got broken at Sphinx 1.5 as
a4orletterended up as option to LaTeX document in place of the neededa4paper, resp.letterpaper. Fixed at 1.7.7.
- SPHINXBUILD
The command to use instead of
sphinx-build.
- BUILDDIR
The build directory to use instead of the one chosen in sphinx-quickstart.
- SPHINXOPTS
Additional options for sphinx-build. These options can also be set via the shortcut variable O (capital 'o').
- NO_COLOR
When set (regardless of value), sphinx-build will not use color in terminal output.
NO_COLORtakes precedence overFORCE_COLOR. See no-color.org for other libraries supporting this community standard.在 4.5.0 版被加入.
- FORCE_COLOR
When set (regardless of value), sphinx-build will use color in terminal output.
NO_COLORtakes precedence overFORCE_COLOR.在 4.5.0 版被加入.
棄用警告¶
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:
另請參見¶
sphinx-quickstart(1)