]> git.lizzy.rs Git - rust.git/blob - tests/ui/doc.rs
Auto merge of #3635 - matthiaskrgr:revert_random_state_3603, r=xfix
[rust.git] / tests / ui / doc.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 //! This file tests for the DOC_MARKDOWN lint
11
12 #![allow(dead_code)]
13 #![warn(clippy::doc_markdown)]
14
15 /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
16 /// Markdown is _weird_. I mean _really weird_.  This \_ is ok. So is `_`. But not Foo::some_fun
17 /// which should be reported only once despite being __doubly bad__.
18 /// Here be ::a::global:path.
19 /// That's not code ~NotInCodeBlock~.
20 /// be_sure_we_got_to_the_end_of_it
21 fn foo_bar() {
22 }
23
24 /// That one tests multiline ticks.
25 /// ```rust
26 /// foo_bar FOO_BAR
27 /// _foo bar_
28 /// ```
29 ///
30 /// ~~~rust
31 /// foo_bar FOO_BAR
32 /// _foo bar_
33 /// ~~~
34 /// be_sure_we_got_to_the_end_of_it
35 fn multiline_codeblock() {
36 }
37
38 /// This _is a test for
39 /// multiline
40 /// emphasis_.
41 /// be_sure_we_got_to_the_end_of_it
42 fn test_emphasis() {
43 }
44
45 /// This tests units. See also #835.
46 /// kiB MiB GiB TiB PiB EiB
47 /// kib Mib Gib Tib Pib Eib
48 /// kB MB GB TB PB EB
49 /// kb Mb Gb Tb Pb Eb
50 /// 32kiB 32MiB 32GiB 32TiB 32PiB 32EiB
51 /// 32kib 32Mib 32Gib 32Tib 32Pib 32Eib
52 /// 32kB 32MB 32GB 32TB 32PB 32EB
53 /// 32kb 32Mb 32Gb 32Tb 32Pb 32Eb
54 /// NaN
55 /// be_sure_we_got_to_the_end_of_it
56 fn test_units() {
57 }
58
59 /// This test has [a link_with_underscores][chunked-example] inside it. See #823.
60 /// See also [the issue tracker](https://github.com/rust-lang/rust-clippy/search?q=clippy::doc_markdown&type=Issues)
61 /// on GitHub (which is a camel-cased word, but is OK). And here is another [inline link][inline_link].
62 /// It can also be [inline_link2].
63 ///
64 /// [chunked-example]: https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example
65 /// [inline_link]: https://foobar
66 /// [inline_link2]: https://foobar
67 /// The `main` function is the entry point of the program. Here it only calls the `foo_bar` and
68 /// `multiline_ticks` functions.
69 ///
70 /// expression of the type  `_ <bit_op> m <cmp_op> c` (where `<bit_op>`
71 /// is one of {`&`, '|'} and `<cmp_op>` is one of {`!=`, `>=`, `>` ,
72 /// be_sure_we_got_to_the_end_of_it
73 fn main() {
74     foo_bar();
75     multiline_codeblock();
76     test_emphasis();
77     test_units();
78 }
79
80 /// ## CamelCaseThing
81 /// Talks about `CamelCaseThing`. Titles should be ignored, see issue #897.
82 ///
83 /// # CamelCaseThing
84 ///
85 /// Not a title #897 CamelCaseThing
86 /// be_sure_we_got_to_the_end_of_it
87 fn issue897() {
88 }
89
90 /// I am confused by brackets? (`x_y`)
91 /// I am confused by brackets? (foo `x_y`)
92 /// I am confused by brackets? (`x_y` foo)
93 /// be_sure_we_got_to_the_end_of_it
94 fn issue900() {
95 }
96
97 /// Diesel queries also have a similar problem to [Iterator][iterator], where
98 /// /// More talking
99 /// returning them from a function requires exposing the implementation of that
100 /// function. The [`helper_types`][helper_types] module exists to help with this,
101 /// but you might want to hide the return type or have it conditionally change.
102 /// Boxing can achieve both.
103 ///
104 /// [iterator]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html
105 /// [helper_types]: ../helper_types/index.html
106 /// be_sure_we_got_to_the_end_of_it
107 fn issue883() {
108 }
109
110 /// `foo_bar
111 /// baz_quz`
112 /// [foo
113 /// bar](https://doc.rust-lang.org/stable/std/iter/trait.IteratorFooBar.html)
114 fn multiline() {
115 }
116
117 /** E.g. serialization of an empty list: FooBar
118 ```
119 That's in a code block: `PackedNode`
120 ```
121
122 And BarQuz too.
123 be_sure_we_got_to_the_end_of_it
124 */
125 fn issue1073() {
126 }
127
128 /** E.g. serialization of an empty list: FooBar
129 ```
130 That's in a code block: PackedNode
131 ```
132
133 And BarQuz too.
134 be_sure_we_got_to_the_end_of_it
135 */
136 fn issue1073_alt() {
137 }
138
139 /// Test more than three quotes:
140 /// ````
141 /// DoNotWarn
142 /// ```
143 /// StillDont
144 /// ````
145 /// be_sure_we_got_to_the_end_of_it
146 fn four_quotes() {
147 }
148
149 /// See [NIST SP 800-56A, revision 2].
150 ///
151 /// [NIST SP 800-56A, revision 2]:
152 ///     https://github.com/rust-lang/rust-clippy/issues/902#issuecomment-261919419
153 fn issue_902_comment() {}
154
155 #[cfg_attr(feature = "a", doc = " ```")]
156 #[cfg_attr(not(feature = "a"), doc = " ```ignore")]
157 /// fn main() {
158 ///     let s = "localhost:10000".to_string();
159 ///     println!("{}", s);
160 /// }
161 /// ```
162 fn issue_1469() {}
163
164 /**
165  * This is a doc comment that should not be a list
166  *This would also be an error under a strict common mark interpretation
167  */
168 fn issue_1920() {}
169
170 /// Ok: <http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels>
171 ///
172 /// Not ok: http://www.unicode.org
173 /// Not ok: https://www.unicode.org
174 /// Not ok: http://www.unicode.org/
175 /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels
176 fn issue_1832() {}
177
178 /// Ok: CamelCase (It should not be surrounded by backticks)
179 fn issue_2395() {}
180
181 /// An iterator over mycrate::Collection's values.
182 /// It should not lint a `'static` lifetime in ticks.
183 fn issue_2210() {}
184
185 /// This should not cause the lint to trigger:
186 /// #REQ-data-family.lint_partof_exists
187 fn issue_2343() {}