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. Valid values:
164
165           ·   human (default): Display in a human-readable text format.
166
167           ·   json: Emit JSON messages to stdout.
168
169           ·   short: Emit shorter, human-readable text messages.
170
171   Manifest Options
172       --manifest-path PATH
173           Path to the Cargo.toml file. By default, Cargo searches in the
174           current directory or any parent directory for the Cargo.toml file.
175
176       --frozen, --locked
177           Either of these flags requires that the Cargo.lock file is
178           up-to-date. If the lock file is missing, or it needs to be updated,
179           Cargo will exit with an error. The --frozen flag also prevents
180           Cargo from attempting to access the network to determine if it is
181           out-of-date.
182
183           These may be used in environments where you want to assert that the
184           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
185           network access.
186
187   Common Options
188       -h, --help
189           Prints help information.
190
191       -Z FLAG...
192           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
193           details.
194
195   Miscellaneous Options
196       -j N, --jobs N
197           Number of parallel jobs to run. May also be specified with the
198           build.jobs config value
199           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
200           to the number of CPUs.
201

PROFILES

203       Profiles may be used to configure compiler options such as optimization
204       levels and debug settings. See the reference
205       <https://doc.rust-lang.org/cargo/reference/manifest.html#the-profile-sections>
206       for more details.
207
208       Profile selection depends on the target and crate being built. By
209       default the dev or test profiles are used. If the --release flag is
210       given, then the release or bench profiles are used.
211
212       ┌────────────────────┬─────────────────┬───────────────────┐
213       │                    │                 │                   │
214       │Target              │ Default Profile │ --release Profile │
215       ├────────────────────┼─────────────────┼───────────────────┤
216       │                    │                 │                   │
217       │lib, bin, example   │ dev             release           
218       ├────────────────────┼─────────────────┼───────────────────┤
219       │                    │                 │                   │
220       │test, bench, or any │ test            bench             
221       │target              │                 │                   │
222       │in "test" or        │                 │                   │
223       │"bench" mode        │                 │                   │
224       └────────────────────┴─────────────────┴───────────────────┘
225
226       Dependencies use the dev/release profiles.
227

ENVIRONMENT

229       See the reference
230       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
231       for details on environment variables that Cargo reads.
232

EXIT STATUS

234       0
235           Cargo succeeded.
236
237       101
238           Cargo failed to complete.
239

EXAMPLES

241        1. Build documentation with custom CSS included from a given file:
242
243               cargo rustdoc --lib -- --extend-css extra.css
244

SEE ALSO

246       cargo(1), cargo-doc(1), rustdoc(1)
247
248
249
250                                  2018-12-20                  CARGO-RUSTDOC(1)
Impressum