Skip to content

Commit 8909830

Browse files
committed
tidy: Run tidy style against markdown files.
1 parent 7fba12b commit 8909830

39 files changed

+177
-139
lines changed

compiler/rustc_infer/src/infer/lexical_region_resolve/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Lexical Region Resolution was removed in https://github.com/rust-lang/rust/pull/64790.
32

43
Rust now uses Non-lexical lifetimes. For more info, please see the [borrowck

src/doc/rustc/src/codegen-options/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ This instructs `rustc` to generate code specifically for a particular processor.
499499
You can run `rustc --print target-cpus` to see the valid options to pass
500500
here. Each target has a default base CPU. Special values include:
501501

502-
* `native` can be passed to use the processor of the host machine.
502+
* `native` can be passed to use the processor of the host machine.
503503
* `generic` refers to an LLVM target with minimal features but modern tuning.
504504

505505
## target-feature

src/doc/rustc/src/exploit-mitigations.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ C library default allocator<sup id="fnref:5" role="doc-noteref"><a
378378
href="#fn:5" class="footnote">5</a></sup> since version 1.32.0
379379
(2019-01-17)[39].
380380

381-
```ignore
381+
```rust,no_run
382382
fn main() {
383383
let mut x = Box::new([0; 1024]);
384384

src/doc/rustc/src/lints/levels.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ warning: unused variable: `x`
6262
A 'deny' lint produces an error if you violate it. For example, this code
6363
runs into the `exceeding_bitshifts` lint.
6464

65-
```rust,ignore
65+
```rust,no_run
6666
fn main() {
6767
100u8 << 10;
6868
}
@@ -232,7 +232,7 @@ pub fn foo() {}
232232
This is the maximum level for all lints. So for example, if we take our
233233
code sample from the "deny" lint level above:
234234
235-
```rust,ignore
235+
```rust,no_run
236236
fn main() {
237237
100u8 << 10;
238238
}

src/doc/rustc/src/lints/listing/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
This section lists out all of the lints, grouped by their default lint levels.
44

5-
You can also see this list by running `rustc -W help`.
5+
You can also see this list by running `rustc -W help`.

src/doc/rustc/src/what-is-rustc.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ $ .\hello.exe # on Windows
3939
Note that we only ever pass `rustc` the *crate root*, not every file we wish
4040
to compile. For example, if we had a `main.rs` that looked like this:
4141

42-
```rust,ignore
42+
```rust,ignore (needs-multiple-files)
4343
mod foo;
4444
4545
fn main() {
@@ -49,7 +49,7 @@ fn main() {
4949

5050
And a `foo.rs` that had this:
5151

52-
```rust,ignore
52+
```rust,no_run
5353
pub fn hello() {
5454
println!("Hello, world!");
5555
}

src/doc/rustdoc/src/advanced-features.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,15 @@ all type errors and name resolution errors with function bodies. Note that this
4747
work for anything outside a function body: since Rustdoc documents your types, it has to
4848
know what those types are! For example, this code will work regardless of the platform:
4949

50-
<!-- `ignore` because doc-tests are run with `rustc`, not `rustdoc` -->
51-
```ignore
50+
```rust,ignore (platform-specific)
5251
pub fn f() {
5352
use std::os::windows::ffi::OsStrExt;
5453
}
5554
```
5655

5756
but this will not, because the unknown type is part of the function signature:
5857

59-
```ignore
58+
```rust,ignore (platform-specific)
6059
pub fn f() -> std::os::windows::ffi::EncodeWide<'static> {
6160
unimplemented!()
6261
}

src/doc/rustdoc/src/documentation-tests.md

+13-7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ that examples within your documentation are up to date and working.
55

66
The basic idea is this:
77

8-
```ignore
8+
```rust,no_run
99
/// # Examples
1010
///
1111
/// ```
1212
/// let x = 5;
1313
/// ```
14+
# fn f() {}
1415
```
1516

1617
The triple backticks start and end code blocks. If this were in a file named `foo.rs`,
@@ -78,12 +79,13 @@ Sometimes, you need some setup code, or other things that would distract
7879
from your example, but are important to make the tests work. Consider
7980
an example block that looks like this:
8081

81-
```ignore
82+
```rust,no_run
8283
/// ```
8384
/// /// Some documentation.
8485
/// # fn foo() {} // this function will be hidden
8586
/// println!("Hello, World!");
8687
/// ```
88+
# fn f() {}
8789
```
8890

8991
It will render like this:
@@ -196,12 +198,13 @@ When writing an example, it is rarely useful to include a complete error
196198
handling, as it would add significant amounts of boilerplate code. Instead, you
197199
may want the following:
198200

199-
```ignore
201+
```rust,no_run
200202
/// ```
201203
/// use std::io;
202204
/// let mut input = String::new();
203205
/// io::stdin().read_line(&mut input)?;
204206
/// ```
207+
# fn f() {}
205208
```
206209

207210
The problem is that `?` returns a `Result<T, E>` and test functions don't
@@ -210,7 +213,7 @@ return anything, so this will give a mismatched types error.
210213
You can get around this limitation by manually adding a `main` that returns
211214
`Result<T, E>`, because `Result<T, E>` implements the `Termination` trait:
212215

213-
```ignore
216+
```rust,no_run
214217
/// A doc test using ?
215218
///
216219
/// ```
@@ -222,12 +225,13 @@ You can get around this limitation by manually adding a `main` that returns
222225
/// Ok(())
223226
/// }
224227
/// ```
228+
# fn f() {}
225229
```
226230

227231
Together with the `# ` from the section above, you arrive at a solution that
228232
appears to the reader as the initial idea but works with doc tests:
229233

230-
```ignore
234+
```rust,no_run
231235
/// ```
232236
/// use std::io;
233237
/// # fn main() -> io::Result<()> {
@@ -236,18 +240,20 @@ appears to the reader as the initial idea but works with doc tests:
236240
/// # Ok(())
237241
/// # }
238242
/// ```
243+
# fn f() {}
239244
```
240245

241246
As of version 1.34.0, one can also omit the `fn main()`, but you will have to
242247
disambiguate the error type:
243248

244-
```ignore
249+
```rust,no_run
245250
/// ```
246251
/// use std::io;
247252
/// let mut input = String::new();
248253
/// io::stdin().read_line(&mut input)?;
249254
/// # Ok::<(), io::Error>(())
250255
/// ```
256+
# fn f() {}
251257
```
252258

253259
This is an unfortunate consequence of the `?` operator adding an implicit
@@ -417,7 +423,7 @@ Another possible use of `#[cfg(doctest)]` is to test doctests that are included
417423
without including it in your main documentation. For example, you could write this into your
418424
`lib.rs` to test your README as part of your doctests:
419425

420-
```rust,ignore
426+
```rust,no_run
421427
#![feature(external_doc)]
422428
423429
#[doc(include = "../README.md")]

src/doc/rustdoc/src/how-to-write-documentation.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ implementation detail, or leaves readers with unanswered questions.
77

88
There are a few tenets to Rust documentation that can help guide anyone through
99
the process of documenting libraries so that everyone has an ample opportunity
10-
to use the code.
10+
to use the code.
1111

1212
This chapter covers not only how to write documentation but specifically
1313
how to write **good** documentation. It is important to be as clear
@@ -19,39 +19,39 @@ then it should be documented.
1919

2020
Documenting a crate should begin with front-page documentation. As an
2121
example, 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
2626
an example of how to use the crate in a real world setting. Stick to the
2727
library'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
3232
rust'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
3535
changes 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

3838
Finally, the front-page can eventually become a comprehensive reference
3939
how 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
4141
provided. The front page goes on to show how to use regular expressions
4242
then concludes with crate features.
4343

4444
Don't worry about comparing your crate, which is just beginning, to other more
4545
developed 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
4747
built in a day!
4848

4949
The first lines within the `lib.rs` will compose the front-page, and they
5050
use a different convention than the rest of the rustdocs. Lines should
5151
start with `//!` which indicate module-level or crate-level documentation.
5252
Here'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.
6565
pub 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
7474
technical details, but with a good description of where this crate fits
7575
within the rust ecosystem. Users should know whether this crate meets their use
7676
case after reading this line.
@@ -95,7 +95,7 @@ It is recommended that each item's documentation follows this basic structure:
9595

9696
This basic structure should be straightforward to follow when writing your
9797
documentation; 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
9999
what an item is, how it is used, and for what purpose it exists.
100100

101101
Let'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
137137
in searches and module overviews. For example, the function `std::env::args()`
138138
above will be shown on the [`std::env`] module documentation. It is good
139139
practice 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/

src/doc/rustdoc/src/lints.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
`rustdoc` provides lints to help you writing and testing your documentation. You
44
can use them like any other lints by doing this:
55

6-
```rust,ignore
6+
```rust
77
#![allow(missing_docs)] // allows the lint, no diagnostics will be reported
88
#![warn(missing_docs)] // warn if there are missing docs
99
#![deny(missing_docs)] // error if there are missing docs
10+
# //! Crate docs.
1011
```
1112

1213
Here is the list of the lints provided by `rustdoc`:

src/doc/rustdoc/src/passes.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ Without this pass, these items will remain in the output.
3232

3333
When you write a doc comment like this:
3434

35-
```rust,ignore
35+
```rust,no_run
3636
/// This is a documentation comment.
37+
# fn f() {}
3738
```
3839

3940
There's a space between the `///` and that `T`. That spacing isn't intended
@@ -52,9 +53,10 @@ documentation string.
5253

5354
For example:
5455

55-
```rust,ignore
56+
```rust,no_run
5657
#[doc = "This is the first line."]
5758
#[doc = "This is the second line."]
59+
# fn f() {}
5860
```
5961

6062
Gets collapsed into a single doc string of
@@ -68,7 +70,7 @@ This is the second line.
6870

6971
This removes documentation for any non-public items, so for example:
7072

71-
```rust,ignore
73+
```rust,no_run
7274
/// These are private docs.
7375
struct Private;
7476

src/doc/rustdoc/src/references.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
There are many great `rustdoc` references out there.
44
If you know of other great resources, please submit a pull request!
55

6-
## Official
6+
## Official
77

88
- [Learn Rust]
99
- [Rust By Example]
1010
- [Rust Reference]
1111
- [RFC 1574: More API Documentation Conventions]
1212
- [RFC 1946: Intra Rustdoc Links]
1313

14-
## Community
14+
## Community
1515
- [API Guidelines]
1616
- [Github tagged RFCs]
1717
- [Github tagged issues]
@@ -28,4 +28,4 @@ If you know of other great resources, please submit a pull request!
2828
[RFC 1946: Intra Rustdoc Links]: https://rust-lang.github.io/rfcs/1946-intra-rustdoc-links.html
2929
[RFC (stalled) front page styleguide]: https://github.com/rust-lang/rfcs/pull/1687
3030
[Rust By Example]: https://doc.rust-lang.org/stable/rust-by-example/meta/doc.html
31-
[Rust Reference]: https://doc.rust-lang.org/stable/reference/comments.html#doc-comments
31+
[Rust Reference]: https://doc.rust-lang.org/stable/reference/comments.html#doc-comments

0 commit comments

Comments
 (0)