1CARGO-RUSTDOC(1)                                              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. To pass flags to all rustdoc
27       processes spawned by Cargo, use the RUSTDOCFLAGS environment variable
28       or the build.rustdocflags configuration option.
29

OPTIONS

31   Documentation Options
32       --open
33           Open the docs in a browser after building them.
34
35   Package Selection
36       By default, the package in the current working directory is selected.
37       The -p flag can be used to choose a different package in a workspace.
38
39       -p SPEC, --package SPEC
40           The package to document. See cargo-pkgid(1) for the SPEC format.
41
42   Target Selection
43       When no target selection options are given, cargo rustdoc will document
44       all binary and library targets of the selected package. The binary will
45       be skipped if its name is the same as the lib target. Binaries are
46       skipped if they have required-features that are missing.
47
48       Passing target selection flags will document only the specified
49       targets.
50
51       --lib
52           Document the package’s library.
53
54       --bin NAME...
55           Document the specified binary. This flag may be specified multiple
56           times.
57
58       --bins
59           Document all binary targets.
60
61       --example NAME...
62           Document the specified example. This flag may be specified multiple
63           times.
64
65       --examples
66           Document all example targets.
67
68       --test NAME...
69           Document the specified integration test. This flag may be specified
70           multiple times.
71
72       --tests
73           Document all targets in test mode that have the test = true
74           manifest flag set. By default this includes the library and
75           binaries built as unittests, and integration tests. Be aware that
76           this will also build any required dependencies, so the lib target
77           may be built twice (once as a unittest, and once as a dependency
78           for binaries, integration tests, etc.). Targets may be enabled or
79           disabled by setting the test flag in the manifest settings for the
80           target.
81
82       --bench NAME...
83           Document the specified benchmark. This flag may be specified
84           multiple times.
85
86       --benches
87           Document all targets in benchmark mode that have the bench = true
88           manifest flag set. By default this includes the library and
89           binaries built as benchmarks, and bench targets. Be aware that this
90           will also build any required dependencies, so the lib target may be
91           built twice (once as a benchmark, and once as a dependency for
92           binaries, benchmarks, etc.). Targets may be enabled or disabled by
93           setting the bench flag in the manifest settings for the target.
94
95       --all-targets
96           Document all targets. This is equivalent to specifying --lib --bins
97           --tests --benches --examples.
98
99   Feature Selection
100       When no feature options are given, the default feature is activated for
101       every selected package.
102
103       --features FEATURES
104           Space or comma separated list of features to activate. These
105           features only apply to the current directory’s package. Features of
106           direct dependencies may be enabled with <dep-name>/<feature-name>
107           syntax.
108
109       --all-features
110           Activate all available features of all selected packages.
111
112       --no-default-features
113           Do not activate the default feature of the current directory’s
114           package.
115
116   Compilation Options
117       --target TRIPLE
118           Document for the given architecture. The default is the host
119           architecture. The general format of the triple is
120           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
121           a list of supported targets.
122
123           This may also be specified with the build.target config value
124           <https://doc.rust-lang.org/cargo/reference/config.html>.
125
126       --release
127           Document optimized artifacts with the release profile. See the
128           PROFILES section for details on how this affects profile selection.
129
130   Output Options
131       --target-dir DIRECTORY
132           Directory for all generated artifacts and intermediate files. May
133           also be specified with the CARGO_TARGET_DIR environment variable,
134           or the build.target-dir config value
135           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
136           to target in the root of the workspace.
137
138   Display Options
139       -v, --verbose
140           Use verbose output. May be specified twice for "very verbose"
141           output which includes extra output such as dependency warnings and
142           build script output. May also be specified with the term.verbose
143           config value
144           <https://doc.rust-lang.org/cargo/reference/config.html>.
145
146       -q, --quiet
147           No output printed to stdout.
148
149       --color WHEN
150           Control when colored output is used. Valid values:
151
152           ·   auto (default): Automatically detect if color support is
153               available on the terminal.
154
155           ·   always: Always display colors.
156
157           ·   never: Never display colors.
158
159           May also be specified with the term.color config value
160           <https://doc.rust-lang.org/cargo/reference/config.html>.
161
162       --message-format FMT
163           The output format for diagnostic messages. Can be specified
164           multiple times and consists of comma-separated values. Valid
165           values:
166
167           ·   human (default): Display in a human-readable text format.
168
169           ·   short: Emit shorter, human-readable text messages.
170
171           ·   json: Emit JSON messages to stdout.
172
173           ·   json-diagnostic-short: Ensure the rendered field of JSON
174               messages contains the "short" rendering from rustc.
175
176           ·   json-diagnostic-rendered-ansi: Ensure the rendered field of
177               JSON messages contains embedded ANSI color codes for respecting
178               rustc’s default color scheme.
179
180           ·   json-render-diagnostics: Instruct Cargo to not include rustc
181               diagnostics in in JSON messages printed, but instead Cargo
182               itself should render the JSON diagnostics coming from rustc.
183               Cargo’s own JSON diagnostics and others coming from rustc are
184               still emitted.
185
186   Manifest Options
187       --manifest-path PATH
188           Path to the Cargo.toml file. By default, Cargo searches in the
189           current directory or any parent directory for the Cargo.toml file.
190
191       --frozen, --locked
192           Either of these flags requires that the Cargo.lock file is
193           up-to-date. If the lock file is missing, or it needs to be updated,
194           Cargo will exit with an error. The --frozen flag also prevents
195           Cargo from attempting to access the network to determine if it is
196           out-of-date.
197
198           These may be used in environments where you want to assert that the
199           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
200           network access.
201
202       --offline
203           Prevents Cargo from accessing the network for any reason. Without
204           this flag, Cargo will stop with an error if it needs to access the
205           network and the network is not available. With this flag, Cargo
206           will attempt to proceed without the network if possible.
207
208           Beware that this may result in different dependency resolution than
209           online mode. Cargo will restrict itself to crates that are
210           downloaded locally, even if there might be a newer version as
211           indicated in the local copy of the index. See the cargo-fetch(1)
212           command to download dependencies before going offline.
213
214           May also be specified with the net.offline config value
215           <https://doc.rust-lang.org/cargo/reference/config.html>.
216
217   Common Options
218       -h, --help
219           Prints help information.
220
221       -Z FLAG...
222           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
223           details.
224
225   Miscellaneous Options
226       -j N, --jobs N
227           Number of parallel jobs to run. May also be specified with the
228           build.jobs config value
229           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
230           to the number of CPUs.
231

PROFILES

233       Profiles may be used to configure compiler options such as optimization
234       levels and debug settings. See the reference
235       <https://doc.rust-lang.org/cargo/reference/manifest.html#the-profile-sections>
236       for more details.
237
238       Profile selection depends on the target and crate being built. By
239       default the dev or test profiles are used. If the --release flag is
240       given, then the release or bench profiles are used.
241
242       ┌────────────────────┬─────────────────┬───────────────────┐
243       │                    │                 │                   │
244       │Target              │ Default Profile │ --release Profile │
245       ├────────────────────┼─────────────────┼───────────────────┤
246       │                    │                 │                   │
247       │lib, bin, example   │ dev             release           
248       ├────────────────────┼─────────────────┼───────────────────┤
249       │                    │                 │                   │
250       │test, bench, or any │ test            bench             
251       │target              │                 │                   │
252       │in "test" or        │                 │                   │
253       │"bench" mode        │                 │                   │
254       └────────────────────┴─────────────────┴───────────────────┘
255
256       Dependencies use the dev/release profiles.
257

ENVIRONMENT

259       See the reference
260       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
261       for details on environment variables that Cargo reads.
262

EXIT STATUS

264       0
265           Cargo succeeded.
266
267       101
268           Cargo failed to complete.
269

EXAMPLES

271        1. Build documentation with custom CSS included from a given file:
272
273               cargo rustdoc --lib -- --extend-css extra.css
274

SEE ALSO

276       cargo(1), cargo-doc(1), rustdoc(1)
277
278
279
280                                  2019-06-07                  CARGO-RUSTDOC(1)
Impressum