Skip to content

Commit a2b8886

Browse files
committed
Implemented #[doc(cfg(...))].
This attribute has two effects: 1. Items with this attribute and their children will have the "This is supported on **** only" message attached in the documentation. 2. The items' doc tests will be skipped if the configuration does not match.
1 parent 8f935fb commit a2b8886

File tree

12 files changed

+1126
-13
lines changed

12 files changed

+1126
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
10+
1. In the annotated item's documentation, there will be a message saying "This is supported on
11+
(platform) only".
12+
13+
2. The item's doc-tests will only run on the specific platform.
14+
15+
This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the
16+
standard library be documented.
17+
18+
```rust
19+
#![feature(doc_cfg)]
20+
21+
#[cfg(any(windows, feature = "documentation"))]
22+
#[doc(cfg(windows))]
23+
/// The application's icon in the notification area (a.k.a. system tray).
24+
///
25+
/// # Examples
26+
///
27+
/// ```no_run
28+
/// extern crate my_awesome_ui_library;
29+
/// use my_awesome_ui_library::current_app;
30+
/// use my_awesome_ui_library::windows::notification;
31+
///
32+
/// let icon = current_app().get::<notification::Icon>();
33+
/// icon.show();
34+
/// icon.show_message("Hello");
35+
/// ```
36+
pub struct Icon {
37+
// ...
38+
}
39+
```
40+
41+
[#43781]: https://github.com/rust-lang/rust/issues/43781
42+
[#43348]: https://github.com/rust-lang/rust/issues/43348

0 commit comments

Comments
 (0)