Documentation
Doc comments are very useful for big projects that require documentation. When
running Rustdoc, these are the comments that get compiled into
documentation. They are denoted by a ///
, and support Markdown.
To run the tests, first build the code as a library, then tell rustdoc where to find the library so it can link it into each doctest program:
$ rustc doc.rs --crate-type lib
$ rustdoc --test --extern doc="libdoc.rlib" doc.rs
(When you run cargo test
on a library crate, Cargo will automatically
generate and run the correct rustc and rustdoc commands.)