Cargo has several types of documentation that contributors work with:
cargo commandBuilding the book requires mdBook. To get it:
$ cargo install mdbook
To build the book:
$ mdbook build
mdbook provides a variety of different commands and options to help you work on the book:
mdbook build --open: Build the book and open it in a web browser.mdbook serve: Launches a web server on localhost. It also automatically rebuilds the book whenever any file changes and automatically reloads your web browser.The book contents are driven by a SUMMARY.md file, and every file must be linked there. See https://rust-lang.github.io/mdBook/ for its usage.
The man pages use a tool called mdman to convert Markdown templates into several output formats. See https://github.com/rust-lang/cargo/tree/master/crates/mdman/doc for usage details and template syntax.
The templates are located in https://github.com/rust-lang/cargo/tree/master/doc/man and are converted into three formats:
cargo help command, and by distributions to provide man pages which people can install, saved in https://github.com/rust-lang/cargo/tree/master/etc/man.man (such as Windows), saved in https://github.com/rust-lang/cargo/tree/master/doc/man/generated_txt.To rebuild the man pages, run cargo build-man inside the workspace.
Cargo‘s documentation is a collective effort, so there isn’t a single fixed writing style. We recommend following the style of the surrounding text to keep things consistent.
A few important guidelines:
../../rustc/codegen-options/index.html. This rule doesn't apply if you specifically want to link to docs of a fixed version or channel.output.html.redirect] mdbook option.[[output.html.redirect]]: https://rust-lang.github.io/mdBook/format/configuration/renderers.html#outputhtmlredirect
There is a script to verify that the examples in the SemVer chapter work as intended. To run the tests, run cargo +stable run -p semver-check.
Note that these tests run on the most recent stable release because they validate the output of the compiler diagnostics. The output can change between releases, so we pin to a specific release to avoid frequent and unexpected breakage.