@@ -7,7 +7,7 @@ implementation detail, or leaves readers with unanswered questions.
77
88There are a few tenets to Rust documentation that can help guide anyone through
99the process of documenting libraries so that everyone has an ample opportunity
10- to use the code.
10+ to use the code.
1111
1212This chapter covers not only how to write documentation but specifically
1313how to write ** good** documentation. It is important to be as clear
@@ -19,39 +19,39 @@ then it should be documented.
1919
2020Documenting a crate should begin with front-page documentation. As an
2121example, the [ ` hashbrown ` ] crate level documentation summarizes the role of
22- the crate, provides links to explain technical details, and explains why you
23- would want to use the crate.
22+ the crate, provides links to explain technical details, and explains why you
23+ would want to use the crate.
2424
25- After introducing the crate, it is important that the front-page gives
25+ After introducing the crate, it is important that the front-page gives
2626an example of how to use the crate in a real world setting. Stick to the
2727library's role in the example, but do so without shortcuts to benefit users who
28- may copy and paste the example to get started.
28+ may copy and paste the example to get started.
2929
3030[ ` futures ` ] uses inline comments to explain line by line
31- the complexities of using a [ ` Future ` ] , because a person's first exposure to
31+ the complexities of using a [ ` Future ` ] , because a person's first exposure to
3232rust's [ ` Future ` ] may be this example.
3333
34- The [ ` backtrace ` ] documentation walks through the whole process, explaining
34+ The [ ` backtrace ` ] documentation walks through the whole process, explaining
3535changes made to the ` Cargo.toml ` file, passing command line arguments to the
36- compiler, and shows a quick example of backtrace in the wild.
36+ compiler, and shows a quick example of backtrace in the wild.
3737
3838Finally, the front-page can eventually become a comprehensive reference
3939how to use a crate, like [ ` regex ` ] . In this front page, all
40- requirements are outlined, the edge cases shown, and practical examples
40+ requirements are outlined, the edge cases shown, and practical examples
4141provided. The front page goes on to show how to use regular expressions
4242then concludes with crate features.
4343
4444Don't worry about comparing your crate, which is just beginning, to other more
4545developed crates. To get the documentation to something more polished, start
46- incrementally and put in an introduction, example, and features. Rome was not
46+ incrementally and put in an introduction, example, and features. Rome was not
4747built in a day!
4848
4949The first lines within the ` lib.rs ` will compose the front-page, and they
5050use a different convention than the rest of the rustdocs. Lines should
5151start with ` //! ` which indicate module-level or crate-level documentation.
5252Here's a quick example of the difference:
5353
54- ``` rust,ignore
54+ ``` rust,no_run
5555//! Fast and easy queue abstraction.
5656//!
5757//! Provides an abstraction over a queue. When the abstraction is used
@@ -64,13 +64,13 @@ Here's a quick example of the difference:
6464/// This module makes it easy.
6565pub mod easy {
6666
67- /// Use the abstract function to do this specific thing.
68- pub fn abstract () {}
67+ /// Use the abstraction function to do this specific thing.
68+ pub fn abstraction () {}
6969
7070}
7171```
7272
73- Ideally, this first line of documentation is a sentence without highly
73+ Ideally, this first line of documentation is a sentence without highly
7474technical details, but with a good description of where this crate fits
7575within the rust ecosystem. Users should know whether this crate meets their use
7676case after reading this line.
@@ -95,7 +95,7 @@ It is recommended that each item's documentation follows this basic structure:
9595
9696This basic structure should be straightforward to follow when writing your
9797documentation; while you might think that a code example is trivial,
98- the examples are really important because they can help users understand
98+ the examples are really important because they can help users understand
9999what an item is, how it is used, and for what purpose it exists.
100100
101101Let's see an example coming from the [ standard library] by taking a look at the
@@ -133,7 +133,7 @@ for argument in env::args() {
133133[`args_os`]: ./fn.args_os.html
134134``````
135135
136- Everything before the first empty line will be reused to describe the component
136+ Everything before the first empty line will be reused to describe the component
137137in searches and module overviews. For example, the function ` std::env::args() `
138138above will be shown on the [ ` std::env ` ] module documentation. It is good
139139practice to keep the summary to one line: concise writing is a goal of good
@@ -163,7 +163,7 @@ interested into taking a look at their website to see what's possible to do.
163163[ commonmark markdown specification ] : https://commonmark.org/
164164[ commonmark quick reference ] : https://commonmark.org/help/
165165[ env::args ] : https://doc.rust-lang.org/stable/std/env/fn.args.html
166- [ ` Future ` ] : https://doc.rust-lang.org/std/future/trait.Future.html
166+ [ `Future` ] : https://doc.rust-lang.org/std/future/trait.Future.html
167167[ `futures` ] : https://docs.rs/futures/0.3.5/futures/
168168[ `hashbrown` ] : https://docs.rs/hashbrown/0.8.2/hashbrown/
169169[ `regex` ] : https://docs.rs/regex/1.3.9/regex/
0 commit comments