]>
Commit | Line | Data |
---|---|---|
0a29b90c FG |
1 | '\" t |
2 | .TH "CARGO\-DOC" "1" | |
3 | .nh | |
4 | .ad l | |
5 | .ss \n[.ss] 0 | |
6 | .SH "NAME" | |
7 | cargo\-doc \[em] Build a package\[cq]s documentation | |
8 | .SH "SYNOPSIS" | |
9 | \fBcargo doc\fR [\fIoptions\fR] | |
10 | .SH "DESCRIPTION" | |
11 | Build the documentation for the local package and all dependencies. The output | |
12 | is placed in \fBtarget/doc\fR in rustdoc\[cq]s usual format. | |
13 | .SH "OPTIONS" | |
14 | .SS "Documentation Options" | |
15 | .sp | |
16 | \fB\-\-open\fR | |
17 | .RS 4 | |
18 | Open the docs in a browser after building them. This will use your default | |
19 | browser unless you define another one in the \fBBROWSER\fR environment variable | |
20 | or use the \fI\f(BIdoc.browser\fI\fR <https://doc.rust\-lang.org/cargo/reference/config.html#docbrowser> configuration | |
21 | option. | |
22 | .RE | |
23 | .sp | |
24 | \fB\-\-no\-deps\fR | |
25 | .RS 4 | |
26 | Do not build documentation for dependencies. | |
27 | .RE | |
28 | .sp | |
29 | \fB\-\-document\-private\-items\fR | |
30 | .RS 4 | |
31 | Include non\-public items in the documentation. This will be enabled by default if documenting a binary target. | |
32 | .RE | |
33 | .SS "Package Selection" | |
34 | By default, when no package selection options are given, the packages selected | |
35 | depend on the selected manifest file (based on the current working directory if | |
36 | \fB\-\-manifest\-path\fR is not given). If the manifest is the root of a workspace then | |
37 | the workspaces default members are selected, otherwise only the package defined | |
38 | by the manifest will be selected. | |
39 | .sp | |
40 | The default members of a workspace can be set explicitly with the | |
41 | \fBworkspace.default\-members\fR key in the root manifest. If this is not set, a | |
42 | virtual workspace will include all workspace members (equivalent to passing | |
43 | \fB\-\-workspace\fR), and a non\-virtual workspace will include only the root crate itself. | |
44 | .sp | |
45 | \fB\-p\fR \fIspec\fR\[u2026], | |
46 | \fB\-\-package\fR \fIspec\fR\[u2026] | |
47 | .RS 4 | |
48 | Document only the specified packages. See \fBcargo\-pkgid\fR(1) for the | |
49 | SPEC format. This flag may be specified multiple times and supports common Unix | |
50 | glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell accidentally | |
51 | expanding glob patterns before Cargo handles them, you must use single quotes or | |
52 | double quotes around each pattern. | |
53 | .RE | |
54 | .sp | |
55 | \fB\-\-workspace\fR | |
56 | .RS 4 | |
57 | Document all members in the workspace. | |
58 | .RE | |
59 | .sp | |
60 | \fB\-\-all\fR | |
61 | .RS 4 | |
62 | Deprecated alias for \fB\-\-workspace\fR\&. | |
63 | .RE | |
64 | .sp | |
65 | \fB\-\-exclude\fR \fISPEC\fR\[u2026] | |
66 | .RS 4 | |
67 | Exclude the specified packages. Must be used in conjunction with the | |
68 | \fB\-\-workspace\fR flag. This flag may be specified multiple times and supports | |
69 | common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell | |
70 | accidentally expanding glob patterns before Cargo handles them, you must use | |
71 | single quotes or double quotes around each pattern. | |
72 | .RE | |
73 | .SS "Target Selection" | |
74 | When no target selection options are given, \fBcargo doc\fR will document all | |
75 | binary and library targets of the selected package. The binary will be skipped | |
76 | if its name is the same as the lib target. Binaries are skipped if they have | |
77 | \fBrequired\-features\fR that are missing. | |
78 | .sp | |
79 | The default behavior can be changed by setting \fBdoc = false\fR for the target in | |
80 | the manifest settings. Using target selection options will ignore the \fBdoc\fR | |
81 | flag and will always document the given target. | |
82 | .sp | |
83 | \fB\-\-lib\fR | |
84 | .RS 4 | |
85 | Document the package\[cq]s library. | |
86 | .RE | |
87 | .sp | |
88 | \fB\-\-bin\fR \fIname\fR\[u2026] | |
89 | .RS 4 | |
90 | Document the specified binary. This flag may be specified multiple times | |
91 | and supports common Unix glob patterns. | |
92 | .RE | |
93 | .sp | |
94 | \fB\-\-bins\fR | |
95 | .RS 4 | |
96 | Document all binary targets. | |
97 | .RE | |
98 | .sp | |
99 | \fB\-\-example\fR \fIname\fR\[u2026] | |
100 | .RS 4 | |
101 | Document the specified example. This flag may be specified multiple times | |
102 | and supports common Unix glob patterns. | |
103 | .RE | |
104 | .sp | |
105 | \fB\-\-examples\fR | |
106 | .RS 4 | |
107 | Document all example targets. | |
108 | .RE | |
109 | .SS "Feature Selection" | |
110 | The feature flags allow you to control which features are enabled. When no | |
111 | feature options are given, the \fBdefault\fR feature is activated for every | |
112 | selected package. | |
113 | .sp | |
114 | See \fIthe features documentation\fR <https://doc.rust\-lang.org/cargo/reference/features.html#command\-line\-feature\-options> | |
115 | for more details. | |
116 | .sp | |
117 | \fB\-F\fR \fIfeatures\fR, | |
118 | \fB\-\-features\fR \fIfeatures\fR | |
119 | .RS 4 | |
120 | Space or comma separated list of features to activate. Features of workspace | |
121 | members may be enabled with \fBpackage\-name/feature\-name\fR syntax. This flag may | |
122 | be specified multiple times, which enables all specified features. | |
123 | .RE | |
124 | .sp | |
125 | \fB\-\-all\-features\fR | |
126 | .RS 4 | |
127 | Activate all available features of all selected packages. | |
128 | .RE | |
129 | .sp | |
130 | \fB\-\-no\-default\-features\fR | |
131 | .RS 4 | |
132 | Do not activate the \fBdefault\fR feature of the selected packages. | |
133 | .RE | |
134 | .SS "Compilation Options" | |
135 | .sp | |
136 | \fB\-\-target\fR \fItriple\fR | |
137 | .RS 4 | |
138 | Document for the given architecture. The default is the host architecture. The general format of the triple is | |
139 | \fB<arch><sub>\-<vendor>\-<sys>\-<abi>\fR\&. Run \fBrustc \-\-print target\-list\fR for a | |
140 | list of supported targets. This flag may be specified multiple times. | |
141 | .sp | |
142 | This may also be specified with the \fBbuild.target\fR | |
143 | \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. | |
144 | .sp | |
145 | Note that specifying this flag makes Cargo run in a different mode where the | |
146 | target artifacts are placed in a separate directory. See the | |
147 | \fIbuild cache\fR <https://doc.rust\-lang.org/cargo/guide/build\-cache.html> documentation for more details. | |
148 | .RE | |
149 | .sp | |
150 | \fB\-r\fR, | |
151 | \fB\-\-release\fR | |
152 | .RS 4 | |
153 | Document optimized artifacts with the \fBrelease\fR profile. | |
154 | See also the \fB\-\-profile\fR option for choosing a specific profile by name. | |
155 | .RE | |
156 | .sp | |
157 | \fB\-\-profile\fR \fIname\fR | |
158 | .RS 4 | |
159 | Document with the given profile. | |
160 | See the \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/profiles.html> for more details on profiles. | |
161 | .RE | |
162 | .sp | |
163 | \fB\-\-ignore\-rust\-version\fR | |
164 | .RS 4 | |
165 | Document the target even if the selected Rust compiler is older than the | |
166 | required Rust version as configured in the project\[cq]s \fBrust\-version\fR field. | |
167 | .RE | |
168 | .sp | |
169 | \fB\-\-timings=\fR\fIfmts\fR | |
170 | .RS 4 | |
171 | Output information how long each compilation takes, and track concurrency | |
172 | information over time. Accepts an optional comma\-separated list of output | |
173 | formats; \fB\-\-timings\fR without an argument will default to \fB\-\-timings=html\fR\&. | |
174 | Specifying an output format (rather than the default) is unstable and requires | |
175 | \fB\-Zunstable\-options\fR\&. Valid output formats: | |
176 | .sp | |
177 | .RS 4 | |
178 | \h'-04'\(bu\h'+02'\fBhtml\fR (unstable, requires \fB\-Zunstable\-options\fR): Write a human\-readable file \fBcargo\-timing.html\fR to the | |
179 | \fBtarget/cargo\-timings\fR directory with a report of the compilation. Also write | |
180 | a report to the same directory with a timestamp in the filename if you want | |
181 | to look at older runs. HTML output is suitable for human consumption only, | |
182 | and does not provide machine\-readable timing data. | |
183 | .RE | |
184 | .sp | |
185 | .RS 4 | |
186 | \h'-04'\(bu\h'+02'\fBjson\fR (unstable, requires \fB\-Zunstable\-options\fR): Emit machine\-readable JSON | |
187 | information about timing information. | |
188 | .RE | |
189 | .RE | |
190 | .SS "Output Options" | |
191 | .sp | |
192 | \fB\-\-target\-dir\fR \fIdirectory\fR | |
193 | .RS 4 | |
194 | Directory for all generated artifacts and intermediate files. May also be | |
195 | specified with the \fBCARGO_TARGET_DIR\fR environment variable, or the | |
196 | \fBbuild.target\-dir\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. | |
197 | Defaults to \fBtarget\fR in the root of the workspace. | |
198 | .RE | |
199 | .SS "Display Options" | |
200 | .sp | |
201 | \fB\-v\fR, | |
202 | \fB\-\-verbose\fR | |
203 | .RS 4 | |
204 | Use verbose output. May be specified twice for \[lq]very verbose\[rq] output which | |
205 | includes extra output such as dependency warnings and build script output. | |
206 | May also be specified with the \fBterm.verbose\fR | |
207 | \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. | |
208 | .RE | |
209 | .sp | |
210 | \fB\-q\fR, | |
211 | \fB\-\-quiet\fR | |
212 | .RS 4 | |
213 | Do not print cargo log messages. | |
214 | May also be specified with the \fBterm.quiet\fR | |
215 | \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. | |
216 | .RE | |
217 | .sp | |
218 | \fB\-\-color\fR \fIwhen\fR | |
219 | .RS 4 | |
220 | Control when colored output is used. Valid values: | |
221 | .sp | |
222 | .RS 4 | |
223 | \h'-04'\(bu\h'+02'\fBauto\fR (default): Automatically detect if color support is available on the | |
224 | terminal. | |
225 | .RE | |
226 | .sp | |
227 | .RS 4 | |
228 | \h'-04'\(bu\h'+02'\fBalways\fR: Always display colors. | |
229 | .RE | |
230 | .sp | |
231 | .RS 4 | |
232 | \h'-04'\(bu\h'+02'\fBnever\fR: Never display colors. | |
233 | .RE | |
234 | .sp | |
235 | May also be specified with the \fBterm.color\fR | |
236 | \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. | |
237 | .RE | |
238 | .sp | |
239 | \fB\-\-message\-format\fR \fIfmt\fR | |
240 | .RS 4 | |
241 | The output format for diagnostic messages. Can be specified multiple times | |
242 | and consists of comma\-separated values. Valid values: | |
243 | .sp | |
244 | .RS 4 | |
245 | \h'-04'\(bu\h'+02'\fBhuman\fR (default): Display in a human\-readable text format. Conflicts with | |
246 | \fBshort\fR and \fBjson\fR\&. | |
247 | .RE | |
248 | .sp | |
249 | .RS 4 | |
250 | \h'-04'\(bu\h'+02'\fBshort\fR: Emit shorter, human\-readable text messages. Conflicts with \fBhuman\fR | |
251 | and \fBjson\fR\&. | |
252 | .RE | |
253 | .sp | |
254 | .RS 4 | |
255 | \h'-04'\(bu\h'+02'\fBjson\fR: Emit JSON messages to stdout. See | |
256 | \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/external\-tools.html#json\-messages> | |
257 | for more details. Conflicts with \fBhuman\fR and \fBshort\fR\&. | |
258 | .RE | |
259 | .sp | |
260 | .RS 4 | |
261 | \h'-04'\(bu\h'+02'\fBjson\-diagnostic\-short\fR: Ensure the \fBrendered\fR field of JSON messages contains | |
262 | the \[lq]short\[rq] rendering from rustc. Cannot be used with \fBhuman\fR or \fBshort\fR\&. | |
263 | .RE | |
264 | .sp | |
265 | .RS 4 | |
266 | \h'-04'\(bu\h'+02'\fBjson\-diagnostic\-rendered\-ansi\fR: Ensure the \fBrendered\fR field of JSON messages | |
267 | contains embedded ANSI color codes for respecting rustc\[cq]s default color | |
268 | scheme. Cannot be used with \fBhuman\fR or \fBshort\fR\&. | |
269 | .RE | |
270 | .sp | |
271 | .RS 4 | |
272 | \h'-04'\(bu\h'+02'\fBjson\-render\-diagnostics\fR: Instruct Cargo to not include rustc diagnostics | |
273 | in JSON messages printed, but instead Cargo itself should render the | |
274 | JSON diagnostics coming from rustc. Cargo\[cq]s own JSON diagnostics and others | |
275 | coming from rustc are still emitted. Cannot be used with \fBhuman\fR or \fBshort\fR\&. | |
276 | .RE | |
277 | .RE | |
278 | .SS "Manifest Options" | |
279 | .sp | |
280 | \fB\-\-manifest\-path\fR \fIpath\fR | |
281 | .RS 4 | |
282 | Path to the \fBCargo.toml\fR file. By default, Cargo searches for the | |
283 | \fBCargo.toml\fR file in the current directory or any parent directory. | |
284 | .RE | |
285 | .sp | |
286 | \fB\-\-frozen\fR, | |
287 | \fB\-\-locked\fR | |
288 | .RS 4 | |
289 | Either of these flags requires that the \fBCargo.lock\fR file is | |
290 | up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will | |
291 | exit with an error. The \fB\-\-frozen\fR flag also prevents Cargo from | |
292 | attempting to access the network to determine if it is out\-of\-date. | |
293 | .sp | |
294 | These may be used in environments where you want to assert that the | |
295 | \fBCargo.lock\fR file is up\-to\-date (such as a CI build) or want to avoid network | |
296 | access. | |
297 | .RE | |
298 | .sp | |
299 | \fB\-\-offline\fR | |
300 | .RS 4 | |
301 | Prevents Cargo from accessing the network for any reason. Without this | |
302 | flag, Cargo will stop with an error if it needs to access the network and | |
303 | the network is not available. With this flag, Cargo will attempt to | |
304 | proceed without the network if possible. | |
305 | .sp | |
306 | Beware that this may result in different dependency resolution than online | |
307 | mode. Cargo will restrict itself to crates that are downloaded locally, even | |
308 | if there might be a newer version as indicated in the local copy of the index. | |
309 | See the \fBcargo\-fetch\fR(1) command to download dependencies before going | |
310 | offline. | |
311 | .sp | |
312 | May also be specified with the \fBnet.offline\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. | |
313 | .RE | |
314 | .SS "Common Options" | |
315 | .sp | |
316 | \fB+\fR\fItoolchain\fR | |
317 | .RS 4 | |
318 | If Cargo has been installed with rustup, and the first argument to \fBcargo\fR | |
319 | begins with \fB+\fR, it will be interpreted as a rustup toolchain name (such | |
320 | as \fB+stable\fR or \fB+nightly\fR). | |
321 | See the \fIrustup documentation\fR <https://rust\-lang.github.io/rustup/overrides.html> | |
322 | for more information about how toolchain overrides work. | |
323 | .RE | |
324 | .sp | |
325 | \fB\-\-config\fR \fIKEY=VALUE\fR or \fIPATH\fR | |
326 | .RS 4 | |
327 | Overrides a Cargo configuration value. The argument should be in TOML syntax of \fBKEY=VALUE\fR, | |
328 | or provided as a path to an extra configuration file. This flag may be specified multiple times. | |
329 | See the \fIcommand\-line overrides section\fR <https://doc.rust\-lang.org/cargo/reference/config.html#command\-line\-overrides> for more information. | |
330 | .RE | |
331 | .sp | |
332 | \fB\-C\fR \fIPATH\fR | |
333 | .RS 4 | |
334 | Changes the current working directory before executing any specified operations. This affects | |
335 | things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as | |
336 | the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. This option must | |
337 | appear before the command name, for example \fBcargo \-C path/to/my\-project build\fR\&. | |
338 | .sp | |
339 | This option is only available on the \fInightly | |
340 | channel\fR <https://doc.rust\-lang.org/book/appendix\-07\-nightly\-rust.html> and | |
341 | requires the \fB\-Z unstable\-options\fR flag to enable (see | |
342 | \fI#10098\fR <https://github.com/rust\-lang/cargo/issues/10098>). | |
343 | .RE | |
344 | .sp | |
345 | \fB\-h\fR, | |
346 | \fB\-\-help\fR | |
347 | .RS 4 | |
348 | Prints help information. | |
349 | .RE | |
350 | .sp | |
351 | \fB\-Z\fR \fIflag\fR | |
352 | .RS 4 | |
353 | Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fR for details. | |
354 | .RE | |
355 | .SS "Miscellaneous Options" | |
356 | .sp | |
357 | \fB\-j\fR \fIN\fR, | |
358 | \fB\-\-jobs\fR \fIN\fR | |
359 | .RS 4 | |
360 | Number of parallel jobs to run. May also be specified with the | |
361 | \fBbuild.jobs\fR \fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&. Defaults to | |
362 | the number of logical CPUs. If negative, it sets the maximum number of | |
fe692bf9 FG |
363 | parallel jobs to the number of logical CPUs plus provided value. If |
364 | a string \fBdefault\fR is provided, it sets the value back to defaults. | |
0a29b90c FG |
365 | Should not be 0. |
366 | .RE | |
367 | .sp | |
368 | \fB\-\-keep\-going\fR | |
369 | .RS 4 | |
370 | Build as many crates in the dependency graph as possible, rather than aborting | |
781aab86 FG |
371 | the build on the first one that fails to build. |
372 | .sp | |
373 | For example if the current package depends on dependencies \fBfails\fR and \fBworks\fR, | |
374 | one of which fails to build, \fBcargo doc \-j1\fR may or may not build the | |
375 | one that succeeds (depending on which one of the two builds Cargo picked to run | |
376 | first), whereas \fBcargo doc \-j1 \-\-keep\-going\fR would definitely run both | |
377 | builds, even if the one run first fails. | |
0a29b90c FG |
378 | .RE |
379 | .SH "ENVIRONMENT" | |
380 | See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for | |
381 | details on environment variables that Cargo reads. | |
382 | .SH "EXIT STATUS" | |
383 | .sp | |
384 | .RS 4 | |
385 | \h'-04'\(bu\h'+02'\fB0\fR: Cargo succeeded. | |
386 | .RE | |
387 | .sp | |
388 | .RS 4 | |
389 | \h'-04'\(bu\h'+02'\fB101\fR: Cargo failed to complete. | |
390 | .RE | |
391 | .SH "EXAMPLES" | |
392 | .sp | |
393 | .RS 4 | |
394 | \h'-04' 1.\h'+01'Build the local package documentation and its dependencies and output to | |
395 | \fBtarget/doc\fR\&. | |
396 | .sp | |
397 | .RS 4 | |
398 | .nf | |
399 | cargo doc | |
400 | .fi | |
401 | .RE | |
402 | .RE | |
403 | .SH "SEE ALSO" | |
404 | \fBcargo\fR(1), \fBcargo\-rustdoc\fR(1), \fBrustdoc\fR(1) |