1CARGO-RUSTDOC(1)            General Commands Manual           CARGO-RUSTDOC(1)
2
3
4

NAME

6       cargo-rustdoc - Build a package's documentation, using specified custom
7       flags
8

SYNOPSIS

10       cargo rustdoc [options] [-- args]
11

DESCRIPTION

13       The specified target for the current package (or package specified by
14       -p if provided) will be documented with the specified args being passed
15       to the final rustdoc invocation. Dependencies will not be documented as
16       part of this command. Note that rustdoc will still unconditionally
17       receive arguments such as -L, --extern, and --crate-type, and the
18       specified args will simply be added to the rustdoc invocation.
19
20       See <https://doc.rust-lang.org/rustdoc/index.html> for documentation on
21       rustdoc flags.
22
23       This command requires that only one target is being compiled when
24       additional arguments are provided. If more than one target is available
25       for the current package the filters of --lib, --bin, etc, must be used
26       to select which target is compiled.
27
28       To pass flags to all rustdoc processes spawned by Cargo, use the
29       RUSTDOCFLAGS environment variable
30       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
31       or the build.rustdocflags config value
32       <https://doc.rust-lang.org/cargo/reference/config.html>.
33

OPTIONS

35   Documentation Options
36       --open
37           Open the docs in a browser after building them. This will use your
38           default browser unless you define another one in the BROWSER
39           environment variable or use the doc.browser
40           <https://doc.rust-lang.org/cargo/reference/config.html#docbrowser>
41           configuration option.
42
43   Package Selection
44       By default, the package in the current working directory is selected.
45       The -p flag can be used to choose a different package in a workspace.
46
47       -p spec, --package spec
48           The package to document. See cargo-pkgid(1) for the SPEC format.
49
50   Target Selection
51       When no target selection options are given, cargo rustdoc will document
52       all binary and library targets of the selected package. The binary will
53       be skipped if its name is the same as the lib target. Binaries are
54       skipped if they have required-features that are missing.
55
56       Passing target selection flags will document only the specified
57       targets.
58
59       Note that --bin, --example, --test and --bench flags also support
60       common Unix glob patterns like *, ? and []. However, to avoid your
61       shell accidentally expanding glob patterns before Cargo handles them,
62       you must use single quotes or double quotes around each glob pattern.
63
64       --lib
65           Document the package's library.
66
67       --bin name...
68           Document the specified binary. This flag may be specified multiple
69           times and supports common Unix glob patterns.
70
71       --bins
72           Document all binary targets.
73
74       --example name...
75           Document the specified example. This flag may be specified multiple
76           times and supports common Unix glob patterns.
77
78       --examples
79           Document all example targets.
80
81       --test name...
82           Document the specified integration test. This flag may be specified
83           multiple times and supports common Unix glob patterns.
84
85       --tests
86           Document all targets in test mode that have the test = true
87           manifest flag set. By default this includes the library and
88           binaries built as unittests, and integration tests. Be aware that
89           this will also build any required dependencies, so the lib target
90           may be built twice (once as a unittest, and once as a dependency
91           for binaries, integration tests, etc.). Targets may be enabled or
92           disabled by setting the test flag in the manifest settings for the
93           target.
94
95       --bench name...
96           Document the specified benchmark. This flag may be specified
97           multiple times and supports common Unix glob patterns.
98
99       --benches
100           Document all targets in benchmark mode that have the bench = true
101           manifest flag set. By default this includes the library and
102           binaries built as benchmarks, and bench targets. Be aware that this
103           will also build any required dependencies, so the lib target may be
104           built twice (once as a benchmark, and once as a dependency for
105           binaries, benchmarks, etc.). Targets may be enabled or disabled by
106           setting the bench flag in the manifest settings for the target.
107
108       --all-targets
109           Document all targets. This is equivalent to specifying --lib --bins
110           --tests --benches --examples.
111
112   Feature Selection
113       The feature flags allow you to control which features are enabled. When
114       no feature options are given, the default feature is activated for
115       every selected package.
116
117       See the features documentation
118       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
119       for more details.
120
121       -F features, --features features
122           Space or comma separated list of features to activate. Features of
123           workspace members may be enabled with package-name/feature-name
124           syntax. This flag may be specified multiple times, which enables
125           all specified features.
126
127       --all-features
128           Activate all available features of all selected packages.
129
130       --no-default-features
131           Do not activate the default feature of the selected packages.
132
133   Compilation Options
134       --target triple
135           Document for the given architecture. The default is the host
136           architecture. The general format of the triple is
137           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
138           a list of supported targets.
139
140           This may also be specified with the build.target config value
141           <https://doc.rust-lang.org/cargo/reference/config.html>.
142
143           Note that specifying this flag makes Cargo run in a different mode
144           where the target artifacts are placed in a separate directory. See
145           the build cache
146           <https://doc.rust-lang.org/cargo/guide/build-cache.html>
147           documentation for more details.
148
149       -r, --release
150           Document optimized artifacts with the release profile. See also the
151           --profile option for choosing a specific profile by name.
152
153       --profile name
154           Document with the given profile. See the the reference
155           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
156           details on profiles.
157
158       --ignore-rust-version
159           Document the target even if the selected Rust compiler is older
160           than the required Rust version as configured in the project's
161           rust-version field.
162
163       --timings=fmts
164           Output information how long each compilation takes, and track
165           concurrency information over time. Accepts an optional
166           comma-separated list of output formats; --timings without an
167           argument will default to --timings=html. Specifying an output
168           format (rather than the default) is unstable and requires
169           -Zunstable-options. Valid output formats:
170
171html: Write a human-readable file cargo-timing.html to the
172               target/cargo-timings directory with a report of the
173               compilation. Also write a report to the same directory with a
174               timestamp in the filename if you want to look at older runs.
175               HTML output is suitable for human consumption only, and does
176               not provide machine-readable timing data.
177
178json (unstable, requires -Zunstable-options): Emit
179               machine-readable JSON information about timing information.
180
181   Output Options
182       --target-dir directory
183           Directory for all generated artifacts and intermediate files. May
184           also be specified with the CARGO_TARGET_DIR environment variable,
185           or the build.target-dir config value
186           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
187           to target in the root of the workspace.
188
189   Display Options
190       -v, --verbose
191           Use verbose output. May be specified twice for "very verbose"
192           output which includes extra output such as dependency warnings and
193           build script output. May also be specified with the term.verbose
194           config value
195           <https://doc.rust-lang.org/cargo/reference/config.html>.
196
197       -q, --quiet
198           Do not print cargo log messages. May also be specified with the
199           term.quiet config value
200           <https://doc.rust-lang.org/cargo/reference/config.html>.
201
202       --color when
203           Control when colored output is used. Valid values:
204
205auto (default): Automatically detect if color support is
206               available on the terminal.
207
208always: Always display colors.
209
210never: Never display colors.
211
212           May also be specified with the term.color config value
213           <https://doc.rust-lang.org/cargo/reference/config.html>.
214
215       --message-format fmt
216           The output format for diagnostic messages. Can be specified
217           multiple times and consists of comma-separated values. Valid
218           values:
219
220human (default): Display in a human-readable text format.
221               Conflicts with short and json.
222
223short: Emit shorter, human-readable text messages. Conflicts
224               with human and json.
225
226json: Emit JSON messages to stdout. See the reference
227               <https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages>
228               for more details. Conflicts with human and short.
229
230json-diagnostic-short: Ensure the rendered field of JSON
231               messages contains the "short" rendering from rustc. Cannot be
232               used with human or short.
233
234json-diagnostic-rendered-ansi: Ensure the rendered field of JSON
235               messages contains embedded ANSI color codes for respecting
236               rustc's default color scheme. Cannot be used with human or
237               short.
238
239json-render-diagnostics: Instruct Cargo to not include rustc
240               diagnostics in in JSON messages printed, but instead Cargo
241               itself should render the JSON diagnostics coming from rustc.
242               Cargo's own JSON diagnostics and others coming from rustc are
243               still emitted. Cannot be used with human or short.
244
245   Manifest Options
246       --manifest-path path
247           Path to the Cargo.toml file. By default, Cargo searches for the
248           Cargo.toml file in the current directory or any parent directory.
249
250       --frozen, --locked
251           Either of these flags requires that the Cargo.lock file is
252           up-to-date. If the lock file is missing, or it needs to be updated,
253           Cargo will exit with an error. The --frozen flag also prevents
254           Cargo from attempting to access the network to determine if it is
255           out-of-date.
256
257           These may be used in environments where you want to assert that the
258           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
259           network access.
260
261       --offline
262           Prevents Cargo from accessing the network for any reason. Without
263           this flag, Cargo will stop with an error if it needs to access the
264           network and the network is not available. With this flag, Cargo
265           will attempt to proceed without the network if possible.
266
267           Beware that this may result in different dependency resolution than
268           online mode. Cargo will restrict itself to crates that are
269           downloaded locally, even if there might be a newer version as
270           indicated in the local copy of the index. See the cargo-fetch(1)
271           command to download dependencies before going offline.
272
273           May also be specified with the net.offline config value
274           <https://doc.rust-lang.org/cargo/reference/config.html>.
275
276   Common Options
277       +toolchain
278           If Cargo has been installed with rustup, and the first argument to
279           cargo begins with +, it will be interpreted as a rustup toolchain
280           name (such as +stable or +nightly). See the rustup documentation
281           <https://rust-lang.github.io/rustup/overrides.html> for more
282           information about how toolchain overrides work.
283
284       -h, --help
285           Prints help information.
286
287       -Z flag
288           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
289           details.
290
291   Miscellaneous Options
292       -j N, --jobs N
293           Number of parallel jobs to run. May also be specified with the
294           build.jobs config value
295           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
296           to the number of CPUs.
297
298       --keep-going
299           Build as many crates in the dependency graph as possible, rather
300           than aborting the build on the first one that fails to build.
301           Unstable, requires -Zunstable-options.
302

ENVIRONMENT

304       See the reference
305       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
306       for details on environment variables that Cargo reads.
307

EXIT STATUS

3090: Cargo succeeded.
310
311101: Cargo failed to complete.
312

EXAMPLES

314        1. Build documentation with custom CSS included from a given file:
315
316               cargo rustdoc --lib -- --extend-css extra.css
317

SEE ALSO

319       cargo(1), cargo-doc(1), rustdoc(1)
320
321
322
323                                                              CARGO-RUSTDOC(1)
Impressum