]>
Commit | Line | Data |
---|---|---|
3b2f2976 XL |
1 | # `doc_cfg` |
2 | ||
3 | The tracking issue for this feature is: [#43781] | |
4 | ||
5 | ------ | |
6 | ||
7 | The `doc_cfg` feature allows an API be documented as only available in some specific platforms. | |
8 | This attribute has two effects: | |
9 | ||
04454e1e | 10 | 1. In the annotated item's documentation, there will be a message saying "Available on |
3b2f2976 XL |
11 | (platform) only". |
12 | ||
13 | 2. The item's doc-tests will only run on the specific platform. | |
14 | ||
b7449926 | 15 | In addition to allowing the use of the `#[doc(cfg)]` attribute, this feature enables the use of a |
60c5eb7d | 16 | special conditional compilation flag, `#[cfg(doc)]`, set whenever building documentation on your |
b7449926 XL |
17 | crate. |
18 | ||
3b2f2976 XL |
19 | This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the |
20 | standard library be documented. | |
21 | ||
22 | ```rust | |
23 | #![feature(doc_cfg)] | |
24 | ||
60c5eb7d | 25 | #[cfg(any(windows, doc))] |
3b2f2976 XL |
26 | #[doc(cfg(windows))] |
27 | /// The application's icon in the notification area (a.k.a. system tray). | |
28 | /// | |
29 | /// # Examples | |
30 | /// | |
31 | /// ```no_run | |
32 | /// extern crate my_awesome_ui_library; | |
33 | /// use my_awesome_ui_library::current_app; | |
34 | /// use my_awesome_ui_library::windows::notification; | |
35 | /// | |
36 | /// let icon = current_app().get::<notification::Icon>(); | |
37 | /// icon.show(); | |
38 | /// icon.show_message("Hello"); | |
39 | /// ``` | |
40 | pub struct Icon { | |
41 | // ... | |
42 | } | |
43 | ``` | |
44 | ||
45 | [#43781]: https://github.com/rust-lang/rust/issues/43781 | |
b7449926 | 46 | [#43348]: https://github.com/rust-lang/rust/issues/43348 |