]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-gui/src/test_docs/lib.rs
Added docs to internal_macro const
[rust.git] / src / test / rustdoc-gui / src / test_docs / lib.rs
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"]
5 #![feature(doc_keyword)]
6 #![feature(doc_cfg)]
7
8 use std::convert::AsRef;
9 use std::fmt;
10
11 /// Basic function with some code examples:
12 ///
13 /// ```
14 /// println!("nothing fancy");
15 /// println!("but with two lines!");
16 /// ```
17 ///
18 /// A failing to compile one:
19 ///
20 /// ```compile_fail
21 /// println!("where did my argument {} go? :'(");
22 /// ```
23 ///
24 /// An ignored one:
25 ///
26 /// ```ignore (it's a test)
27 /// Let's say I'm just some text will ya?
28 /// ```
29 ///
30 /// An inlined `code`!
31 pub fn foo() {}
32
33 /// Just a normal struct.
34 pub struct Foo;
35
36 impl Foo {
37     #[must_use]
38     pub fn must_use(&self) -> bool {
39         true
40     }
41 }
42
43 impl AsRef<str> for Foo {
44     fn as_ref(&self) -> &str {
45         "hello"
46     }
47 }
48
49 /// Just a normal enum.
50 #[doc(alias = "ThisIsAnAlias")]
51 pub enum WhoLetTheDogOut {
52     /// Woof!
53     Woof,
54     /// Meoooooooow...
55     Meow,
56 }
57
58 /// Who doesn't love to wrap a `format!` call?
59 pub fn some_more_function<T: fmt::Debug>(t: &T) -> String {
60     format!("{:?}", t)
61 }
62
63 /// Woohoo! A trait!
64 pub trait AnotherOne {
65     /// Some func 3.
66     fn func3();
67
68     /// Some func 1.
69     fn func1();
70
71     fn another();
72     fn why_not();
73
74     /// Some func 2.
75     fn func2();
76
77     fn hello();
78 }
79
80 /// ```compile_fail
81 /// whatever
82 /// ```
83 ///
84 /// Check for "i" signs in lists!
85 ///
86 /// 1. elem 1
87 /// 2. test 1
88 ///    ```compile_fail
89 ///    fn foo() {}
90 ///    ```
91 /// 3. elem 3
92 /// 4. ```ignore (it's a test)
93 ///    fn foo() {}
94 ///    ```
95 /// 5. elem 5
96 ///
97 /// Final one:
98 ///
99 /// ```ignore (still a test)
100 /// let x = 12;
101 /// ```
102 pub fn check_list_code_block() {}
103
104 /// a thing with a label
105 #[deprecated(since = "1.0.0", note = "text why this deprecated")]
106 #[doc(cfg(unix))]
107 pub fn replaced_function() {}
108
109 /// Some doc with `code`!
110 pub enum AnEnum {
111     WithVariants { and: usize, sub: usize, variants: usize },
112 }
113
114 #[doc(keyword = "CookieMonster")]
115 /// Some keyword.
116 pub mod keyword {}
117
118 /// Just some type alias.
119 pub type SomeType = u32;
120
121 pub mod huge_amount_of_consts {
122     include!(concat!(env!("OUT_DIR"), "/huge_amount_of_consts.rs"));
123 }
124
125 /// Very long code text `hereIgoWithLongTextBecauseWhyNotAndWhyWouldntI`.
126 pub mod long_code_block {}
127
128 #[macro_export]
129 macro_rules! repro {
130     () => {};
131 }
132
133 pub use crate::repro as repro2;