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