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 current working directory. In the root of a
29       virtual workspace, all workspace members are selected (--all is
30       implied). Otherwise, only the package in the current directory will be
31       selected. The default packages may be overridden with the
32       workspace.default-members key in the root Cargo.toml manifest.
33
34       -p SPEC..., --package SPEC...
35           Document only the specified packages. See cargo-pkgid(1) for the
36           SPEC format. This flag may be specified multiple times.
37
38       --all
39           Document all members in the workspace.
40
41       --exclude SPEC...
42           Exclude the specified packages. Must be used in conjunction with
43           the --all flag. This flag may be specified multiple times.
44
45   Target Selection
46       When no target selection options are given, cargo doc will document all
47       binary and library targets of the selected package. The binary will be
48       skipped if its name is the same as the lib target. Binaries are skipped
49       if they have required-features that are missing.
50
51       The default behavior can be changed by setting doc = false for the
52       target in the manifest settings. Using target selection options will
53       ignore the doc flag and will always document the given target.
54
55       --lib
56           Document the package’s library.
57
58       --bin NAME...
59           Document the specified binary. This flag may be specified multiple
60           times.
61
62       --bins
63           Document all binary targets.
64
65   Feature Selection
66       When no feature options are given, the default feature is activated for
67       every selected package.
68
69       --features FEATURES
70           Space or comma separated list of features to activate. These
71           features only apply to the current directory’s package. Features of
72           direct dependencies may be enabled with <dep-name>/<feature-name>
73           syntax.
74
75       --all-features
76           Activate all available features of all selected packages.
77
78       --no-default-features
79           Do not activate the default feature of the current directory’s
80           package.
81
82   Compilation Options
83       --target TRIPLE
84           Document for the given architecture. The default is the host
85           architecture. The general format of the triple is
86           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
87           a list of supported targets.
88
89           This may also be specified with the build.target config value
90           <https://doc.rust-lang.org/cargo/reference/config.html>.
91
92       --release
93           Document optimized artifacts with the release profile. See the
94           PROFILES section for details on how this affects profile selection.
95
96   Output Options
97       --target-dir DIRECTORY
98           Directory for all generated artifacts and intermediate files. May
99           also be specified with the CARGO_TARGET_DIR environment variable,
100           or the build.target-dir config value
101           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
102           to target in the root of the workspace.
103
104   Display Options
105       -v, --verbose
106           Use verbose output. May be specified twice for "very verbose"
107           output which includes extra output such as dependency warnings and
108           build script output. May also be specified with the term.verbose
109           config value
110           <https://doc.rust-lang.org/cargo/reference/config.html>.
111
112       -q, --quiet
113           No output printed to stdout.
114
115       --color WHEN
116           Control when colored output is used. Valid values:
117
118           ·   auto (default): Automatically detect if color support is
119               available on the terminal.
120
121           ·   always: Always display colors.
122
123           ·   never: Never display colors.
124
125           May also be specified with the term.color config value
126           <https://doc.rust-lang.org/cargo/reference/config.html>.
127
128       --message-format FMT
129           The output format for diagnostic messages. Valid values:
130
131           ·   human (default): Display in a human-readable text format.
132
133           ·   json: Emit JSON messages to stdout.
134
135           ·   short: Emit shorter, human-readable text messages.
136
137   Manifest Options
138       --manifest-path PATH
139           Path to the Cargo.toml file. By default, Cargo searches in the
140           current directory or any parent directory for the Cargo.toml file.
141
142       --frozen, --locked
143           Either of these flags requires that the Cargo.lock file is
144           up-to-date. If the lock file is missing, or it needs to be updated,
145           Cargo will exit with an error. The --frozen flag also prevents
146           Cargo from attempting to access the network to determine if it is
147           out-of-date.
148
149           These may be used in environments where you want to assert that the
150           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
151           network access.
152
153   Common Options
154       -h, --help
155           Prints help information.
156
157       -Z FLAG...
158           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
159           details.
160
161   Miscellaneous Options
162       -j N, --jobs N
163           Number of parallel jobs to run. May also be specified with the
164           build.jobs config value
165           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
166           to the number of CPUs.
167

PROFILES

169       Profiles may be used to configure compiler options such as optimization
170       levels and debug settings. See the reference
171       <https://doc.rust-lang.org/cargo/reference/manifest.html#the-profile-sections>
172       for more details.
173
174       Profile selection depends on the target and crate being built. By
175       default the dev or test profiles are used. If the --release flag is
176       given, then the release or bench profiles are used.
177
178       ┌────────────────────┬─────────────────┬───────────────────┐
179       │                    │                 │                   │
180       │Target              │ Default Profile │ --release Profile │
181       ├────────────────────┼─────────────────┼───────────────────┤
182       │                    │                 │                   │
183       │lib, bin, example   │ dev             release           
184       ├────────────────────┼─────────────────┼───────────────────┤
185       │                    │                 │                   │
186       │test, bench, or any │ test            bench             
187       │target              │                 │                   │
188       │in "test" or        │                 │                   │
189       │"bench" mode        │                 │                   │
190       └────────────────────┴─────────────────┴───────────────────┘
191
192       Dependencies use the dev/release profiles.
193

ENVIRONMENT

195       See the reference
196       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
197       for details on environment variables that Cargo reads.
198

EXIT STATUS

200       0
201           Cargo succeeded.
202
203       101
204           Cargo failed to complete.
205

EXAMPLES

207        1. Build the local package documentation and its dependencies and
208           output to target/doc.
209
210               cargo doc
211

SEE ALSO

213       cargo(1), cargo-rustdoc(1), rustdoc(1)
214
215
216
217                                  2018-12-20                      CARGO-DOC(1)
Impressum