如何使用Cargo下载箱子的文档?

时间:2016-03-05 23:26:41

标签: rust rust-cargo

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

1 个答案:

答案 0 :(得分:7)

您可以使用命令cargo doc Cargo.toml 中当前指定的所有包装箱构建文档。可以在cargo --help找到常用货物命令列表,可以在cargo COMMAND --help找到命令的详细信息:

$ cargo doc --help

Build a package's documentation

Usage:
    cargo doc [options]

Options:
    -h, --help                   Print this message
    --open                       Opens the docs in a browser after the operation
    -p SPEC, --package SPEC ...  Package to document
    --no-deps                    Don't build documentation for dependencies
    -j N, --jobs N               The number of jobs to run in parallel
    --release                    Build artifacts in release mode, with optimizations
    --features FEATURES          Space-separated list of features to also build
    --no-default-features        Do not build the `default` feature
    --target TRIPLE              Build for the target triple
    --manifest-path PATH         Path to the manifest to document
    -v, --verbose                Use verbose output
    -q, --quiet                  No output printed to stdout
    --color WHEN                 Coloring: auto, always, never

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.

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项目,将所需的crates添加为依赖项,然后按照上述步骤操作。