在Haskell的Cabal中,可以下载软件包的文档。在Rust的Cargo中是否也可以呢?我在互联网上搜索了一下,但没有找到答案。
在Rust的Cargo中是否也可以下载软件包文档?我在互联网上搜索了一下,但是没有找到答案。
在Rust的Cargo中是否也可以下载软件包文档?我在互联网上搜索了一下,但是没有找到答案。
您可以使用命令构建当前在Cargo.toml中指定的所有板条箱的文档。
cargo doc
您可以使用 cargo --help
查看常见的 Cargo 命令列表,使用 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项目,将所需的包添加到依赖项中,然后按照上述步骤操作。