1CARGO-DOC(1)                                                      CARGO-DOC(1)
2
3
4

NAME

6       cargo-doc - Build a package's documentation
7

SYNOPSIS

9       cargo doc [OPTIONS]
10

DESCRIPTION

12       Build the documentation for the local package and all dependencies. The
13       output is placed in target/doc in rustdoc’s usual format.
14

OPTIONS

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

PROFILES

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

ENVIRONMENT

234       See the reference
235       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
236       for details on environment variables that Cargo reads.
237

EXIT STATUS

239       0
240           Cargo succeeded.
241
242       101
243           Cargo failed to complete.
244

EXAMPLES

246        1. Build the local package documentation and its dependencies and
247           output to target/doc.
248
249               cargo doc
250

SEE ALSO

252       cargo(1), cargo-rustdoc(1), rustdoc(1)
253
254
255
256                                  2019-08-19                      CARGO-DOC(1)
Impressum