← 返回命令列表

Linux command

sphinx-build 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Build HTML documentation

sphinx-build -b html [source/] [build/html]

Build PDF documentation

sphinx-build -b latex [source/] [build/latex]

Clean and rebuild

sphinx-build -E -b html [source/] [build/html]

Verbose output

sphinx-build -v -b html [source/] [build/html]

Build with warnings as errors

sphinx-build -W -b html [source/] [build/html]

Check links

sphinx-build -b linkcheck [source/] [build/linkcheck]

Set configuration option

sphinx-build -D [key=value] -b html [source/] [build/]

说明

sphinx-build is the build command for Sphinx, the standard documentation generator for Python projects. It reads reStructuredText or MyST Markdown source files and produces output in various formats including HTML websites, LaTeX/PDF documents, ePub ebooks, and Unix man pages. The build process is controlled by a conf.py configuration file in the source directory, which defines the project name, theme, enabled extensions, and output settings. Sphinx supports automatic cross-referencing between documents, index generation, and code syntax highlighting. The autodoc extension can extract documentation directly from Python docstrings. Multiple builders are available, selected with the -b flag. Incremental builds only process changed files by default; the -E flag forces a complete rebuild. Parallel building with -j speeds up large documentation projects.

参数

-b _BUILDER_
Output format builder.
-E
Rebuild all files.
-a
Rebuild changed files.
-W
Warnings as errors.
-v
Verbose output.
-D _KEY=VALUE_
Override config.
-c _PATH_
Config directory.
-j _N_
Parallel jobs.

FAQ

What is the sphinx-build command used for?

sphinx-build is the build command for Sphinx, the standard documentation generator for Python projects. It reads reStructuredText or MyST Markdown source files and produces output in various formats including HTML websites, LaTeX/PDF documents, ePub ebooks, and Unix man pages. The build process is controlled by a conf.py configuration file in the source directory, which defines the project name, theme, enabled extensions, and output settings. Sphinx supports automatic cross-referencing between documents, index generation, and code syntax highlighting. The autodoc extension can extract documentation directly from Python docstrings. Multiple builders are available, selected with the -b flag. Incremental builds only process changed files by default; the -E flag forces a complete rebuild. Parallel building with -j speeds up large documentation projects.

How do I run a basic sphinx-build example?

Run `sphinx-build -b html [source/] [build/html]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -b _BUILDER_ do in sphinx-build?

Output format builder.