]> git.proxmox.com Git - rustc.git/blame - src/test/rustdoc-gui/src/test_docs/lib.rs
New upstream version 1.57.0+dfsg1
[rustc.git] / src / test / rustdoc-gui / src / test_docs / lib.rs
CommitLineData
6a06907d
XL
1//! The point of this crate is to be able to have enough different "kinds" of
2//! documentation generated so we can test each different features.
3
4#![crate_name = "test_docs"]
17df50a5 5#![feature(doc_keyword)]
136023e0 6#![feature(doc_cfg)]
6a06907d 7
136023e0 8use std::convert::AsRef;
6a06907d
XL
9use std::fmt;
10
11/// Basic function with some code examples:
12///
13/// ```
14/// println!("nothing fancy");
15/// ```
16///
17/// A failing to compile one:
18///
19/// ```compile_fail
20/// println!("where did my argument {} go? :'(");
21/// ```
22///
23/// An ignored one:
24///
25/// ```ignore (it's a test)
26/// Let's say I'm just some text will ya?
27/// ```
94222f64
XL
28///
29/// An inlined `code`!
6a06907d
XL
30pub fn foo() {}
31
32/// Just a normal struct.
33pub struct Foo;
34
35impl Foo {
36 #[must_use]
cdc7bbd5
XL
37 pub fn must_use(&self) -> bool {
38 true
39 }
6a06907d
XL
40}
41
136023e0
XL
42impl AsRef<str> for Foo {
43 fn as_ref(&self) -> &str {
44 "hello"
45 }
46}
47
6a06907d 48/// Just a normal enum.
17df50a5 49#[doc(alias = "ThisIsAnAlias")]
6a06907d
XL
50pub enum WhoLetTheDogOut {
51 /// Woof!
52 Woof,
53 /// Meoooooooow...
54 Meow,
55}
56
57/// Who doesn't love to wrap a `format!` call?
58pub fn some_more_function<T: fmt::Debug>(t: &T) -> String {
59 format!("{:?}", t)
60}
61
62/// Woohoo! A trait!
63pub trait AnotherOne {
cdc7bbd5
XL
64 /// Some func 3.
65 fn func3();
66
6a06907d
XL
67 /// Some func 1.
68 fn func1();
69
cdc7bbd5
XL
70 fn another();
71 fn why_not();
72
6a06907d
XL
73 /// Some func 2.
74 fn func2();
75
cdc7bbd5 76 fn hello();
6a06907d
XL
77}
78
cdc7bbd5
XL
79/// ```compile_fail
80/// whatever
81/// ```
82///
6a06907d
XL
83/// Check for "i" signs in lists!
84///
85/// 1. elem 1
cdc7bbd5
XL
86/// 2. test 1
87/// ```compile_fail
88/// fn foo() {}
89/// ```
6a06907d
XL
90/// 3. elem 3
91/// 4. ```ignore (it's a test)
92/// fn foo() {}
93/// ```
94/// 5. elem 5
cdc7bbd5
XL
95///
96/// Final one:
97///
98/// ```ignore (still a test)
99/// let x = 12;
100/// ```
6a06907d 101pub fn check_list_code_block() {}
cdc7bbd5 102
136023e0
XL
103/// a thing with a label
104#[deprecated(since = "1.0.0", note = "text why this deprecated")]
105#[doc(cfg(unix))]
106pub fn replaced_function() {}
107
108/// Some doc with `code`!
cdc7bbd5
XL
109pub enum AnEnum {
110 WithVariants { and: usize, sub: usize, variants: usize },
111}
17df50a5
XL
112
113#[doc(keyword = "CookieMonster")]
136023e0 114/// Some keyword.
17df50a5
XL
115pub mod keyword {}
116
117/// Just some type alias.
118pub type SomeType = u32;
c295e0f8
XL
119
120pub mod huge_amount_of_consts {
121 include!(concat!(env!("OUT_DIR"), "/huge_amount_of_consts.rs"));
122}
123
124/// Very long code text `hereIgoWithLongTextBecauseWhyNotAndWhyWouldntI`.
125pub mod long_code_block {}
126
127/// # Top-doc Prose title
128///
129/// Text below title.
130///
131/// ## Top-doc Prose sub-heading
132///
133/// Text below sub-heading.
134///
135/// ### Top-doc Prose sub-sub-heading
136///
137/// Text below sub-sub-heading
138pub struct HeavilyDocumentedStruct {
139 /// # Title for field
140 /// ## Sub-heading for field
141 pub nothing: (),
142}
143
144/// # Title for struct impl doc
145///
146/// Text below heading.
147///
148/// ## Sub-heading for struct impl doc
149///
150/// Text below sub-heading.
151///
152/// ### Sub-sub-heading for struct impl doc
153///
154/// Text below sub-sub-heading.
155///
156impl HeavilyDocumentedStruct {
157 /// # Title for struct impl-item doc
158 /// Text below title.
159 /// ## Sub-heading for struct impl-item doc
160 /// Text below sub-heading.
161 /// ### Sub-sub-heading for struct impl-item doc
162 /// Text below sub-sub-heading.
163 pub fn do_nothing() {}
164}
165
166/// # Top-doc Prose title
167///
168/// Text below title.
169///
170/// ## Top-doc Prose sub-heading
171///
172/// Text below sub-heading.
173///
174/// ### Top-doc Prose sub-sub-heading
175///
176/// Text below sub-sub-heading
177pub enum HeavilyDocumentedEnum {
178 /// # None prose title
179 /// ## None prose sub-heading
180 None,
181 /// # Wrapped prose title
182 /// ## Wrapped prose sub-heading
183 Wrapped(
184 /// # Wrapped.0 prose title
185 /// ## Wrapped.0 prose sub-heading
186 String,
187 String,
188 ),
189 Structy {
190 /// # Structy prose title
191 /// ## Structy prose sub-heading
192 alpha: String,
193 beta: String,
194 },
195}
196
197/// # Title for enum impl doc
198///
199/// Text below heading.
200///
201/// ## Sub-heading for enum impl doc
202///
203/// Text below sub-heading.
204///
205/// ### Sub-sub-heading for enum impl doc
206///
207/// Text below sub-sub-heading.
208///
209impl HeavilyDocumentedEnum {
210 /// # Title for enum impl-item doc
211 /// Text below title.
212 /// ## Sub-heading for enum impl-item doc
213 /// Text below sub-heading.
214 /// ### Sub-sub-heading for enum impl-item doc
215 /// Text below sub-sub-heading.
216 pub fn do_nothing() {}
217}
218
219/// # Top-doc prose title
220///
221/// Text below heading.
222///
223/// ## Top-doc prose sub-heading
224///
225/// Text below heading.
226pub union HeavilyDocumentedUnion {
227 /// # Title for union variant
228 /// ## Sub-heading for union variant
229 pub nothing: (),
230 pub something: f32,
231}
232
233/// # Title for union impl doc
234/// ## Sub-heading for union impl doc
235impl HeavilyDocumentedUnion {
236 /// # Title for union impl-item doc
237 /// ## Sub-heading for union impl-item doc
238 pub fn do_nothing() {}
239}
240
241/// # Top-doc prose title
242///
243/// Text below heading.
244///
245/// ## Top-doc prose sub-heading
246///
247/// Text below heading.
248#[macro_export]
249macro_rules! heavily_documented_macro {
250 () => {};
251}