2 {{*set actionverb="Document"}}
3 {{*set multitarget=true}}
7 cargo-doc --- Build a package's documentation
11 `cargo doc` [_options_]
15 Build the documentation for the local package and all dependencies. The output
16 is placed in `target/doc` in rustdoc's usual format.
20 ### Documentation Options
24 {{#option "`--open`" }}
25 Open the docs in a browser after building them. This will use your default
26 browser unless you define another one in the `BROWSER` environment variable
27 or use the [`doc.browser`](../reference/config.html#docbrowser) configuration
31 {{#option "`--no-deps`" }}
32 Do not build documentation for dependencies.
35 {{#option "`--document-private-items`" }}
36 Include non-public items in the documentation. This will be enabled by default if documenting a binary target.
41 {{> section-package-selection }}
45 When no target selection options are given, `cargo doc` will document all
46 binary and library targets of the selected package. The binary will be skipped
47 if its name is the same as the lib target. Binaries are skipped if they have
48 `required-features` that are missing.
50 The default behavior can be changed by setting `doc = false` for the target in
51 the manifest settings. Using target selection options will ignore the `doc`
52 flag and will always document the given target.
55 {{> options-targets-lib-bin }}
57 {{#option "`--example` _name_..." }}
58 {{actionverb}} the specified example. This flag may be specified multiple times
59 and supports common Unix glob patterns.
62 {{#option "`--examples`" }}
63 {{actionverb}} all example targets.
68 {{> section-features }}
70 ### Compilation Options
74 {{> options-target-triple }}
76 {{> options-release }}
78 {{> options-profile }}
80 {{> options-ignore-rust-version }}
82 {{> options-timings }}
89 {{> options-target-dir }}
95 {{> options-display }}
97 {{> options-message-format }}
103 {{> options-manifest-path }}
105 {{> options-locked }}
108 {{> section-options-common }}
110 ### Miscellaneous Options
114 {{> options-keep-going }}
117 {{> section-environment }}
119 {{> section-exit-status }}
123 1. Build the local package documentation and its dependencies and output to
129 {{man "cargo" 1}}, {{man "cargo-rustdoc" 1}}, {{man "rustdoc" 1}}