]> git.proxmox.com Git - rustc.git/blame - src/doc/unstable-book/src/language-features/doc-cfg.md
New upstream version 1.41.1+dfsg1
[rustc.git] / src / doc / unstable-book / src / language-features / doc-cfg.md
CommitLineData
3b2f2976
XL
1# `doc_cfg`
2
3The tracking issue for this feature is: [#43781]
4
5------
6
7The `doc_cfg` feature allows an API be documented as only available in some specific platforms.
8This attribute has two effects:
9
101. In the annotated item's documentation, there will be a message saying "This is supported on
11 (platform) only".
12
132. The item's doc-tests will only run on the specific platform.
14
b7449926 15In addition to allowing the use of the `#[doc(cfg)]` attribute, this feature enables the use of a
60c5eb7d 16special conditional compilation flag, `#[cfg(doc)]`, set whenever building documentation on your
b7449926
XL
17crate.
18
3b2f2976
XL
19This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the
20standard 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/// ```
40pub 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