A list of common Cargo commands can be found with cargo --help, and detailed information for a command can be found with cargo COMMAND --help:$ cargo doc --helpcargo-doc Build a package's documentationUSAGE: cargo doc [OPTIONS]OPTIONS: -q, --quiet No output printed to stdout --open Opens the docs in a browser after the operation -p, --package <SPEC>... Package to document --all Document all packages in the workspace --exclude <SPEC>... Exclude packages from the build --no-deps Don't build documentation for dependencies --document-private-items Document private items -j, --jobs <N> Number of parallel jobs, defaults to # of CPUs --lib Document only this package's library --bin <NAME>... Document only the specified binary --bins Document all binaries --release Build artifacts in release mode, with optimizations --features <FEATURES> Space-separated list of features to activate --all-features Activate all available features --no-default-features Do not activate the `default` feature --target <TRIPLE> Build for the target triple --target-dir <DIRECTORY> Directory for all generated artifacts --manifest-path <PATH> Path to Cargo.toml --message-format <FMT> Error format [default: human] [possible values: human, json, short] -v, --verbose Use verbose output (-vv very verbose/build.rs output) --color <WHEN> Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date --offline Run without accessing the network -Z <FLAG>... Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details -h, --help Prints help informationBy default the documentation for the local package and all dependencies isbuilt. The output is all placed in `target/doc` in rustdoc's usual format.All packages in the workspace are documented if the `--all` flag is supplied. The`--all` flag is automatically assumed for a virtual manifest.Note that `--exclude` has to be specified in conjunction with the `--all` flag.If the `--package` argument is given, then SPEC is a package ID specificationwhich indicates which package should be documented. If it is not given, then thecurrent package is documented. For more information on SPEC and its format, seethe `cargo help pkgid` command.对我特别有用的是 --open 标志,它可以在浏览器中打开生成的文档.Especially useful to me is the --open flag, which opens the generated documentation in a browser.我不相信有任何方法可以为您不使用的任意包生成文档.您可以随时创建一个新的 Cargo 项目,添加所需的 crate 作为依赖项,然后按照上述步骤操作.I do not believe that there is any way to generate the documentation for an arbitrary package that you are not using. You could always create a new Cargo project, add the desired crates as dependencies, then follow the above steps. 这篇关于如何使用 Cargo 下载 crate 的文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-23 11:33