]> git.proxmox.com Git - rustc.git/blame - src/tools/cargo/src/etc/man/cargo-doc.1
New upstream version 1.74.1+dfsg1
[rustc.git] / src / tools / cargo / src / etc / man / cargo-doc.1
CommitLineData
0a29b90c
FG
1'\" t
2.TH "CARGO\-DOC" "1"
3.nh
4.ad l
5.ss \n[.ss] 0
6.SH "NAME"
7cargo\-doc \[em] Build a package\[cq]s documentation
8.SH "SYNOPSIS"
9\fBcargo doc\fR [\fIoptions\fR]
10.SH "DESCRIPTION"
11Build the documentation for the local package and all dependencies. The output
12is 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
18Open the docs in a browser after building them. This will use your default
19browser unless you define another one in the \fBBROWSER\fR environment variable
20or use the \fI\f(BIdoc.browser\fI\fR <https://doc.rust\-lang.org/cargo/reference/config.html#docbrowser> configuration
21option.
22.RE
23.sp
24\fB\-\-no\-deps\fR
25.RS 4
26Do not build documentation for dependencies.
27.RE
28.sp
29\fB\-\-document\-private\-items\fR
30.RS 4
31Include non\-public items in the documentation. This will be enabled by default if documenting a binary target.
32.RE
33.SS "Package Selection"
34By default, when no package selection options are given, the packages selected
35depend 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
37the workspaces default members are selected, otherwise only the package defined
38by the manifest will be selected.
39.sp
40The 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
42virtual 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
48Document only the specified packages. See \fBcargo\-pkgid\fR(1) for the
49SPEC format. This flag may be specified multiple times and supports common Unix
50glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell accidentally
51expanding glob patterns before Cargo handles them, you must use single quotes or
52double quotes around each pattern.
53.RE
54.sp
55\fB\-\-workspace\fR
56.RS 4
57Document all members in the workspace.
58.RE
59.sp
60\fB\-\-all\fR
61.RS 4
62Deprecated alias for \fB\-\-workspace\fR\&.
63.RE
64.sp
65\fB\-\-exclude\fR \fISPEC\fR\[u2026]
66.RS 4
67Exclude the specified packages. Must be used in conjunction with the
68\fB\-\-workspace\fR flag. This flag may be specified multiple times and supports
69common Unix glob patterns like \fB*\fR, \fB?\fR and \fB[]\fR\&. However, to avoid your shell
70accidentally expanding glob patterns before Cargo handles them, you must use
71single quotes or double quotes around each pattern.
72.RE
73.SS "Target Selection"
74When no target selection options are given, \fBcargo doc\fR will document all
75binary and library targets of the selected package. The binary will be skipped
76if its name is the same as the lib target. Binaries are skipped if they have
77\fBrequired\-features\fR that are missing.
78.sp
79The default behavior can be changed by setting \fBdoc = false\fR for the target in
80the manifest settings. Using target selection options will ignore the \fBdoc\fR
81flag and will always document the given target.
82.sp
83\fB\-\-lib\fR
84.RS 4
85Document the package\[cq]s library.
86.RE
87.sp
88\fB\-\-bin\fR \fIname\fR\[u2026]
89.RS 4
90Document the specified binary. This flag may be specified multiple times
91and supports common Unix glob patterns.
92.RE
93.sp
94\fB\-\-bins\fR
95.RS 4
96Document all binary targets.
97.RE
98.sp
99\fB\-\-example\fR \fIname\fR\[u2026]
100.RS 4
101Document the specified example. This flag may be specified multiple times
102and supports common Unix glob patterns.
103.RE
104.sp
105\fB\-\-examples\fR
106.RS 4
107Document all example targets.
108.RE
109.SS "Feature Selection"
110The feature flags allow you to control which features are enabled. When no
111feature options are given, the \fBdefault\fR feature is activated for every
112selected package.
113.sp
114See \fIthe features documentation\fR <https://doc.rust\-lang.org/cargo/reference/features.html#command\-line\-feature\-options>
115for more details.
116.sp
117\fB\-F\fR \fIfeatures\fR,
118\fB\-\-features\fR \fIfeatures\fR
119.RS 4
120Space or comma separated list of features to activate. Features of workspace
121members may be enabled with \fBpackage\-name/feature\-name\fR syntax. This flag may
122be specified multiple times, which enables all specified features.
123.RE
124.sp
125\fB\-\-all\-features\fR
126.RS 4
127Activate all available features of all selected packages.
128.RE
129.sp
130\fB\-\-no\-default\-features\fR
131.RS 4
132Do 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
138Document 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
140list of supported targets. This flag may be specified multiple times.
141.sp
142This may also be specified with the \fBbuild.target\fR
143\fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&.
144.sp
145Note that specifying this flag makes Cargo run in a different mode where the
146target 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
153Document optimized artifacts with the \fBrelease\fR profile.
154See 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
159Document with the given profile.
160See 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
165Document the target even if the selected Rust compiler is older than the
166required 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
171Output information how long each compilation takes, and track concurrency
172information over time. Accepts an optional comma\-separated list of output
173formats; \fB\-\-timings\fR without an argument will default to \fB\-\-timings=html\fR\&.
174Specifying 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
180a report to the same directory with a timestamp in the filename if you want
181to look at older runs. HTML output is suitable for human consumption only,
182and 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
187information about timing information.
188.RE
189.RE
190.SS "Output Options"
191.sp
192\fB\-\-target\-dir\fR \fIdirectory\fR
193.RS 4
194Directory for all generated artifacts and intermediate files. May also be
195specified 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>\&.
197Defaults 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
204Use verbose output. May be specified twice for \[lq]very verbose\[rq] output which
205includes extra output such as dependency warnings and build script output.
206May 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
213Do not print cargo log messages.
214May 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
220Control 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
224terminal.
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
235May 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
241The output format for diagnostic messages. Can be specified multiple times
242and 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
251and \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>
257for 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
262the \[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
267contains embedded ANSI color codes for respecting rustc\[cq]s default color
268scheme. 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
273in JSON messages printed, but instead Cargo itself should render the
274JSON diagnostics coming from rustc. Cargo\[cq]s own JSON diagnostics and others
275coming 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
282Path 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
289Either of these flags requires that the \fBCargo.lock\fR file is
290up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will
291exit with an error. The \fB\-\-frozen\fR flag also prevents Cargo from
292attempting to access the network to determine if it is out\-of\-date.
293.sp
294These 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
296access.
297.RE
298.sp
299\fB\-\-offline\fR
300.RS 4
301Prevents Cargo from accessing the network for any reason. Without this
302flag, Cargo will stop with an error if it needs to access the network and
303the network is not available. With this flag, Cargo will attempt to
304proceed without the network if possible.
305.sp
306Beware that this may result in different dependency resolution than online
307mode. Cargo will restrict itself to crates that are downloaded locally, even
308if there might be a newer version as indicated in the local copy of the index.
309See the \fBcargo\-fetch\fR(1) command to download dependencies before going
310offline.
311.sp
312May 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
318If Cargo has been installed with rustup, and the first argument to \fBcargo\fR
319begins with \fB+\fR, it will be interpreted as a rustup toolchain name (such
320as \fB+stable\fR or \fB+nightly\fR).
321See the \fIrustup documentation\fR <https://rust\-lang.github.io/rustup/overrides.html>
322for more information about how toolchain overrides work.
323.RE
324.sp
325\fB\-\-config\fR \fIKEY=VALUE\fR or \fIPATH\fR
326.RS 4
327Overrides a Cargo configuration value. The argument should be in TOML syntax of \fBKEY=VALUE\fR,
328or provided as a path to an extra configuration file. This flag may be specified multiple times.
329See 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
334Changes the current working directory before executing any specified operations. This affects
335things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as
336the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. This option must
337appear before the command name, for example \fBcargo \-C path/to/my\-project build\fR\&.
338.sp
339This option is only available on the \fInightly
340channel\fR <https://doc.rust\-lang.org/book/appendix\-07\-nightly\-rust.html> and
341requires 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
348Prints help information.
349.RE
350.sp
351\fB\-Z\fR \fIflag\fR
352.RS 4
353Unstable (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
360Number 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
362the number of logical CPUs. If negative, it sets the maximum number of
fe692bf9
FG
363parallel jobs to the number of logical CPUs plus provided value. If
364a string \fBdefault\fR is provided, it sets the value back to defaults.
0a29b90c
FG
365Should not be 0.
366.RE
367.sp
368\fB\-\-keep\-going\fR
369.RS 4
370Build as many crates in the dependency graph as possible, rather than aborting
781aab86
FG
371the build on the first one that fails to build.
372.sp
373For example if the current package depends on dependencies \fBfails\fR and \fBworks\fR,
374one of which fails to build, \fBcargo doc \-j1\fR may or may not build the
375one that succeeds (depending on which one of the two builds Cargo picked to run
376first), whereas \fBcargo doc \-j1 \-\-keep\-going\fR would definitely run both
377builds, even if the one run first fails.
0a29b90c
FG
378.RE
379.SH "ENVIRONMENT"
380See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/environment\-variables.html> for
381details 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
399cargo doc
400.fi
401.RE
402.RE
403.SH "SEE ALSO"
404\fBcargo\fR(1), \fBcargo\-rustdoc\fR(1), \fBrustdoc\fR(1)