В Haskell's Cabal можно загрузить документацию для пакета. Возможно ли это с Rust's Cargo? Я искал в Интернете, но ничего не нашел.
Как скачать документацию на ящик с Cargo?
Ответы (1)
Вы можете создать документацию для всех ящиков, которые в настоящее время указаны в вашем Cargo.toml, используя команду
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, добавить желаемые ящики в качестве зависимостей, а затем выполнить описанные выше шаги.
person
Shepmaster
schedule
05.03.2016