gpt4 book ai didi

rust - 如何使用 Cargo 下载 crate 的文档?

转载 作者:行者123 更新时间:2023-11-29 07:49:30 24 4
gpt4 key购买 nike

在 Haskell 的 Cabal 中,可以下载包的文档。 Rust 的 Cargo 有可能吗?我在 Internet 上搜索但一无所获。

最佳答案

您可以使用以下命令为您的 Cargo.toml 中当前指定的所有 crate 构建文档

cargo doc

常用 Cargo 命令列表可以通过 cargo --help 找到,命令的详细信息可以通过 cargo COMMAND --help 找到:

$ cargo doc --help
cargo-doc
Build a package's documentation

USAGE:
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 information

By default the documentation for the local package and all dependencies is
built. 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 specification
which indicates which package should be documented. If it is not given, then the
current package is documented. For more information on SPEC and its format, see
the `cargo help pkgid` command.

对我特别有用的是 --open 标志,它可以在浏览器中打开生成的文档。

我认为没有任何方法可以为您未使用的任意包生成文档。您始终可以创建一个新的 Cargo 项目,将所需的箱子添加为依赖项,然后按照上述步骤操作。

关于rust - 如何使用 Cargo 下载 crate 的文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35821185/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com