|
1 | 1 | # Documentation
|
2 | 2 |
|
| 3 | +Use `cargo doc` to build documentation in `target/doc`. |
| 4 | + |
| 5 | +Use `cargo test` to run all tests (including documentation tests), and `cargo test --doc` to only run documentation tests. |
| 6 | + |
| 7 | +These commands will appropriately invoke `rustdoc` (and `rustc`) as required. |
| 8 | + |
| 9 | +### Doc comments |
| 10 | + |
3 | 11 | Doc comments are very useful for big projects that require documentation. When
|
4 |
| -running [Rustdoc][1], these are the comments that get compiled into |
5 |
| -documentation. They are denoted by a `///`, and support [Markdown][2]. |
| 12 | +running Rustdoc, these are the comments that get compiled into |
| 13 | +documentation. They are denoted by a `///`, and support [Markdown]. |
6 | 14 |
|
7 | 15 | ```rust,editable,ignore
|
8 | 16 | #![crate_name = "doc"]
|
@@ -57,8 +65,19 @@ $ rustc doc.rs --crate-type lib
|
57 | 65 | $ rustdoc --test --extern doc="libdoc.rlib" doc.rs
|
58 | 66 | ```
|
59 | 67 |
|
60 |
| -(When you run `cargo test` on a library crate, Cargo will automatically |
61 |
| -generate and run the correct rustc and rustdoc commands.) |
| 68 | +### See also: |
| 69 | + |
| 70 | +* [The Rust Book: Making Useful Documentation Comments][book] |
| 71 | +* [The Rustdoc Book][rustdoc-book] |
| 72 | +* [The Reference: Doc comments][ref-comments] |
| 73 | +* [RFC 1574: API Documentation Conventions][api-conv] |
| 74 | +* [RFC 1946: Relative links to other items from doc comments (intra-rustdoc links)][intra-links] |
| 75 | +* [Is there any documentation style guide for comments? (reddit)][reddit] |
62 | 76 |
|
63 |
| -[1]: https://doc.rust-lang.org/book/documentation.html |
64 |
| -[2]: https://en.wikipedia.org/wiki/Markdown |
| 77 | +[Markdown]: https://en.wikipedia.org/wiki/Markdown |
| 78 | +[book]: https://doc.rust-lang.org/book/ch14-02-publishing-to-crates-io.html#making-useful-documentation-comments |
| 79 | +[ref-comments]: https://doc.rust-lang.org/stable/reference/comments.html#doc-comments |
| 80 | +[rustdoc-book]: https://doc.rust-lang.org/rustdoc/index.html |
| 81 | +[api-conv]: https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text |
| 82 | +[intra-links]: https://rust-lang.github.io/rfcs/1946-intra-rustdoc-links.html |
| 83 | +[reddit]: https://www.reddit.com/r/rust/comments/ahb50s/is_there_any_documentation_style_guide_for/ |
0 commit comments