blob: 88271e1462a880e93b1cfa363cc4115164ca6b35 [file] [log] [blame]
Jeff Vander Stoep956d1432020-09-18 13:46:24 +02001'\" t
2.\" Title: cargo-rustdoc
3.\" Author: [see the "AUTHOR(S)" section]
4.\" Generator: Asciidoctor 2.0.10
5.\" Date: 2020-06-25
6.\" Manual: \ \&
7.\" Source: \ \&
8.\" Language: English
9.\"
10.TH "CARGO\-RUSTDOC" "1" "2020-06-25" "\ \&" "\ \&"
11.ie \n(.g .ds Aq \(aq
12.el .ds Aq '
13.ss \n[.ss] 0
14.nh
15.ad l
16.de URL
17\fI\\$2\fP <\\$1>\\$3
18..
19.als MTO URL
20.if \n[.g] \{\
21. mso www.tmac
22. am URL
23. ad l
24. .
25. am MTO
26. ad l
27. .
28. LINKSTYLE blue R < >
29.\}
30.SH "NAME"
31cargo\-rustdoc \- Build a package\(aqs documentation, using specified custom flags
32.SH "SYNOPSIS"
33.sp
34\fBcargo rustdoc [\fIOPTIONS\fP] [\-\- \fIARGS\fP]\fP
35.SH "DESCRIPTION"
36.sp
37The specified target for the current package (or package specified by \fB\-p\fP if
38provided) will be documented with the specified \fIARGS\fP being passed to the
39final rustdoc invocation. Dependencies will not be documented as part of this
40command. Note that rustdoc will still unconditionally receive arguments such
41as \fB\-L\fP, \fB\-\-extern\fP, and \fB\-\-crate\-type\fP, and the specified \fIARGS\fP will simply
42be added to the rustdoc invocation.
43.sp
44See \c
45.URL "https://doc.rust\-lang.org/rustdoc/index.html" "" " "
46for documentation on rustdoc
47flags.
48.sp
49This command requires that only one target is being compiled when additional
50arguments are provided. If more than one target is available for the current
51package the filters of \fB\-\-lib\fP, \fB\-\-bin\fP, etc, must be used to select which
52target is compiled.
53To pass flags to all rustdoc processes spawned by Cargo, use the
54\fBRUSTDOCFLAGS\fP \c
55.URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "environment variable"
56or the \fBbuild.rustdocflags\fP \c
57.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
58.SH "OPTIONS"
59.SS "Documentation Options"
60.sp
61\fB\-\-open\fP
62.RS 4
63Open the docs in a browser after building them. This will use your default
64browser unless you define another one in the \fBBROWSER\fP environment
65variable.
66.RE
67.SS "Package Selection"
68.sp
69By default, the package in the current working directory is selected. The \fB\-p\fP
70flag can be used to choose a different package in a workspace.
71.sp
72\fB\-p\fP \fISPEC\fP, \fB\-\-package\fP \fISPEC\fP
73.RS 4
74The package to document. See \fBcargo\-pkgid\fP(1) for
75the SPEC format.
76.RE
77.SS "Target Selection"
78.sp
79When no target selection options are given, \fBcargo rustdoc\fP will document all
80binary and library targets of the selected package. The binary will be skipped
81if its name is the same as the lib target. Binaries are skipped if they have
82\fBrequired\-features\fP that are missing.
83.sp
84Passing target selection flags will document only the
85specified targets.
86.sp
87\fB\-\-lib\fP
88.RS 4
89Document the package\(cqs library.
90.RE
91.sp
92\fB\-\-bin\fP \fINAME\fP...
93.RS 4
94Document the specified binary. This flag may be specified multiple times.
95.RE
96.sp
97\fB\-\-bins\fP
98.RS 4
99Document all binary targets.
100.RE
101.sp
102\fB\-\-example\fP \fINAME\fP...
103.RS 4
104Document the specified example. This flag may be specified multiple times.
105.RE
106.sp
107\fB\-\-examples\fP
108.RS 4
109Document all example targets.
110.RE
111.sp
112\fB\-\-test\fP \fINAME\fP...
113.RS 4
114Document the specified integration test. This flag may be specified multiple
115times.
116.RE
117.sp
118\fB\-\-tests\fP
119.RS 4
120Document all targets in test mode that have the \fBtest = true\fP manifest
121flag set. By default this includes the library and binaries built as
122unittests, and integration tests. Be aware that this will also build any
123required dependencies, so the lib target may be built twice (once as a
124unittest, and once as a dependency for binaries, integration tests, etc.).
125Targets may be enabled or disabled by setting the \fBtest\fP flag in the
126manifest settings for the target.
127.RE
128.sp
129\fB\-\-bench\fP \fINAME\fP...
130.RS 4
131Document the specified benchmark. This flag may be specified multiple times.
132.RE
133.sp
134\fB\-\-benches\fP
135.RS 4
136Document all targets in benchmark mode that have the \fBbench = true\fP
137manifest flag set. By default this includes the library and binaries built
138as benchmarks, and bench targets. Be aware that this will also build any
139required dependencies, so the lib target may be built twice (once as a
140benchmark, and once as a dependency for binaries, benchmarks, etc.).
141Targets may be enabled or disabled by setting the \fBbench\fP flag in the
142manifest settings for the target.
143.RE
144.sp
145\fB\-\-all\-targets\fP
146.RS 4
147Document all targets. This is equivalent to specifying \fB\-\-lib \-\-bins
148\-\-tests \-\-benches \-\-examples\fP.
149.RE
150.SS "Feature Selection"
151.sp
152The feature flags allow you to control the enabled features for the "current"
153package. The "current" package is the package in the current directory, or the
154one specified in \fB\-\-manifest\-path\fP. If running in the root of a virtual
155workspace, then the default features are selected for all workspace members,
156or all features if \fB\-\-all\-features\fP is specified.
157.sp
158When no feature options are given, the \fBdefault\fP feature is activated for
159every selected package.
160.sp
161\fB\-\-features\fP \fIFEATURES\fP
162.RS 4
163Space or comma separated list of features to activate. These features only
164apply to the current directory\(cqs package. Features of direct dependencies
165may be enabled with \fB<dep\-name>/<feature\-name>\fP syntax. This flag may be
166specified multiple times, which enables all specified features.
167.RE
168.sp
169\fB\-\-all\-features\fP
170.RS 4
171Activate all available features of all selected packages.
172.RE
173.sp
174\fB\-\-no\-default\-features\fP
175.RS 4
176Do not activate the \fBdefault\fP feature of the current directory\(cqs
177package.
178.RE
179.SS "Compilation Options"
180.sp
181\fB\-\-target\fP \fITRIPLE\fP
182.RS 4
183Document for the given architecture. The default is the host
184architecture. The general format of the triple is
185\fB<arch><sub>\-<vendor>\-<sys>\-<abi>\fP. Run \fBrustc \-\-print target\-list\fP for a
186list of supported targets.
187.sp
188This may also be specified with the \fBbuild.target\fP
189.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
190.sp
191Note that specifying this flag makes Cargo run in a different mode where the
192target artifacts are placed in a separate directory. See the
193.URL "https://doc.rust\-lang.org/cargo/guide/build\-cache.html" "build cache" " "
194documentation for more details.
195.RE
196.sp
197\fB\-\-release\fP
198.RS 4
199Document optimized artifacts with the \fBrelease\fP profile. See the
200PROFILES section for details on how this affects profile selection.
201.RE
202.SS "Output Options"
203.sp
204\fB\-\-target\-dir\fP \fIDIRECTORY\fP
205.RS 4
206Directory for all generated artifacts and intermediate files. May also be
207specified with the \fBCARGO_TARGET_DIR\fP environment variable, or the
208\fBbuild.target\-dir\fP \c
209.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
210Defaults
211to \fBtarget\fP in the root of the workspace.
212.RE
213.SS "Display Options"
214.sp
215\fB\-v\fP, \fB\-\-verbose\fP
216.RS 4
217Use verbose output. May be specified twice for "very verbose" output which
218includes extra output such as dependency warnings and build script output.
219May also be specified with the \fBterm.verbose\fP
220.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
221.RE
222.sp
223\fB\-q\fP, \fB\-\-quiet\fP
224.RS 4
225No output printed to stdout.
226.RE
227.sp
228\fB\-\-color\fP \fIWHEN\fP
229.RS 4
230Control when colored output is used. Valid values:
231.sp
232.RS 4
233.ie n \{\
234\h'-04'\(bu\h'+03'\c
235.\}
236.el \{\
237. sp -1
238. IP \(bu 2.3
239.\}
240\fBauto\fP (default): Automatically detect if color support is available on the
241terminal.
242.RE
243.sp
244.RS 4
245.ie n \{\
246\h'-04'\(bu\h'+03'\c
247.\}
248.el \{\
249. sp -1
250. IP \(bu 2.3
251.\}
252\fBalways\fP: Always display colors.
253.RE
254.sp
255.RS 4
256.ie n \{\
257\h'-04'\(bu\h'+03'\c
258.\}
259.el \{\
260. sp -1
261. IP \(bu 2.3
262.\}
263\fBnever\fP: Never display colors.
264.RE
265.sp
266May also be specified with the \fBterm.color\fP
267.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
268.RE
269.sp
270\fB\-\-message\-format\fP \fIFMT\fP
271.RS 4
272The output format for diagnostic messages. Can be specified multiple times
273and consists of comma\-separated values. Valid values:
274.sp
275.RS 4
276.ie n \{\
277\h'-04'\(bu\h'+03'\c
278.\}
279.el \{\
280. sp -1
281. IP \(bu 2.3
282.\}
283\fBhuman\fP (default): Display in a human\-readable text format.
284.RE
285.sp
286.RS 4
287.ie n \{\
288\h'-04'\(bu\h'+03'\c
289.\}
290.el \{\
291. sp -1
292. IP \(bu 2.3
293.\}
294\fBshort\fP: Emit shorter, human\-readable text messages.
295.RE
296.sp
297.RS 4
298.ie n \{\
299\h'-04'\(bu\h'+03'\c
300.\}
301.el \{\
302. sp -1
303. IP \(bu 2.3
304.\}
305\fBjson\fP: Emit JSON messages to stdout. See
306\c
307.URL "https://doc.rust\-lang.org/cargo/reference/external\-tools.html#json\-messages" "the reference"
308for more details.
309.RE
310.sp
311.RS 4
312.ie n \{\
313\h'-04'\(bu\h'+03'\c
314.\}
315.el \{\
316. sp -1
317. IP \(bu 2.3
318.\}
319\fBjson\-diagnostic\-short\fP: Ensure the \fBrendered\fP field of JSON messages contains
320the "short" rendering from rustc.
321.RE
322.sp
323.RS 4
324.ie n \{\
325\h'-04'\(bu\h'+03'\c
326.\}
327.el \{\
328. sp -1
329. IP \(bu 2.3
330.\}
331\fBjson\-diagnostic\-rendered\-ansi\fP: Ensure the \fBrendered\fP field of JSON messages
332contains embedded ANSI color codes for respecting rustc\(cqs default color
333scheme.
334.RE
335.sp
336.RS 4
337.ie n \{\
338\h'-04'\(bu\h'+03'\c
339.\}
340.el \{\
341. sp -1
342. IP \(bu 2.3
343.\}
344\fBjson\-render\-diagnostics\fP: Instruct Cargo to not include rustc diagnostics in
345in JSON messages printed, but instead Cargo itself should render the
346JSON diagnostics coming from rustc. Cargo\(cqs own JSON diagnostics and others
347coming from rustc are still emitted.
348.RE
349.RE
350.SS "Manifest Options"
351.sp
352\fB\-\-manifest\-path\fP \fIPATH\fP
353.RS 4
354Path to the \fBCargo.toml\fP file. By default, Cargo searches for the
355\fBCargo.toml\fP file in the current directory or any parent directory.
356.RE
357.sp
358\fB\-\-frozen\fP, \fB\-\-locked\fP
359.RS 4
360Either of these flags requires that the \fBCargo.lock\fP file is
361up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will
362exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from
363attempting to access the network to determine if it is out\-of\-date.
364.sp
365These may be used in environments where you want to assert that the
366\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
367access.
368.RE
369.sp
370\fB\-\-offline\fP
371.RS 4
372Prevents Cargo from accessing the network for any reason. Without this
373flag, Cargo will stop with an error if it needs to access the network and
374the network is not available. With this flag, Cargo will attempt to
375proceed without the network if possible.
376.sp
377Beware that this may result in different dependency resolution than online
378mode. Cargo will restrict itself to crates that are downloaded locally, even
379if there might be a newer version as indicated in the local copy of the index.
380See the \fBcargo\-fetch\fP(1) command to download dependencies before going
381offline.
382.sp
383May also be specified with the \fBnet.offline\fP \c
384.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
385.RE
386.SS "Common Options"
387.sp
388\fB+TOOLCHAIN\fP
389.RS 4
390If Cargo has been installed with rustup, and the first argument to \fBcargo\fP
391begins with \fB+\fP, it will be interpreted as a rustup toolchain name (such
392as \fB+stable\fP or \fB+nightly\fP).
393See the \c
394.URL "https://github.com/rust\-lang/rustup/" "rustup documentation"
395for more information about how toolchain overrides work.
396.RE
397.sp
398\fB\-h\fP, \fB\-\-help\fP
399.RS 4
400Prints help information.
401.RE
402.sp
403\fB\-Z\fP \fIFLAG\fP...
404.RS 4
405Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for
406details.
407.RE
408.SS "Miscellaneous Options"
409.sp
410\fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP
411.RS 4
412Number of parallel jobs to run. May also be specified with the
413\fBbuild.jobs\fP \c
414.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
415Defaults to
416the number of CPUs.
417.RE
418.SH "PROFILES"
419.sp
420Profiles may be used to configure compiler options such as optimization levels
421and debug settings. See
422\c
423.URL "https://doc.rust\-lang.org/cargo/reference/profiles.html" "the reference"
424for more details.
425.sp
426Profile selection depends on the target and crate being built. By default the
427\fBdev\fP or \fBtest\fP profiles are used. If the \fB\-\-release\fP flag is given, then the
428\fBrelease\fP or \fBbench\fP profiles are used.
429.TS
430allbox tab(:);
431lt lt lt.
432T{
433.sp
434Target
435T}:T{
436.sp
437Default Profile
438T}:T{
439.sp
440\fB\-\-release\fP Profile
441T}
442T{
443.sp
444lib, bin, example
445T}:T{
446.sp
447\fBdev\fP
448T}:T{
449.sp
450\fBrelease\fP
451T}
452T{
453.sp
454test, bench, or any target
455.br
456in "test" or "bench" mode
457T}:T{
458.sp
459\fBtest\fP
460T}:T{
461.sp
462\fBbench\fP
463T}
464.TE
465.sp
466.sp
467Dependencies use the \fBdev\fP/\fBrelease\fP profiles.
468.SH "ENVIRONMENT"
469.sp
470See \c
471.URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " "
472for
473details on environment variables that Cargo reads.
474.SH "EXIT STATUS"
475.sp
4760
477.RS 4
478Cargo succeeded.
479.RE
480.sp
481101
482.RS 4
483Cargo failed to complete.
484.RE
485.SH "EXAMPLES"
486.sp
487.RS 4
488.ie n \{\
489\h'-04' 1.\h'+01'\c
490.\}
491.el \{\
492. sp -1
493. IP " 1." 4.2
494.\}
495Build documentation with custom CSS included from a given file:
496.sp
497.if n .RS 4
498.nf
499cargo rustdoc \-\-lib \-\- \-\-extend\-css extra.css
500.fi
501.if n .RE
502.RE
503.SH "SEE ALSO"
504.sp
505\fBcargo\fP(1), \fBcargo\-doc\fP(1), \fBrustdoc\fP(1)