about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2017-08-05 14:38:52 +0800
committerkennytm <kennytm@gmail.com>2017-08-10 13:43:59 +0800
commita2b888675accccedec7601cc3bd67ca028b4757c (patch)
treea13d255f58f1e86112774af9e8c297871adf5834 /src/doc
parent8f935fbb5b7e8ea5a320082cb9e28095aa0b5759 (diff)
downloadrust-a2b888675accccedec7601cc3bd67ca028b4757c.tar.gz
rust-a2b888675accccedec7601cc3bd67ca028b4757c.zip
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.
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/unstable-book/src/language-features/doc-cfg.md42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/doc-cfg.md b/src/doc/unstable-book/src/language-features/doc-cfg.md
new file mode 100644
index 00000000000..ddc538e1214
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/doc-cfg.md
@@ -0,0 +1,42 @@
+# `doc_cfg`
+
+The tracking issue for this feature is: [#43781]
+
+------
+
+The `doc_cfg` feature allows an API be documented as only available in some specific platforms.
+This attribute has two effects:
+
+1. In the annotated item's documentation, there will be a message saying "This is supported on
+    (platform) only".
+
+2. The item's doc-tests will only run on the specific platform.
+
+This feature was introduced as part of PR [#43348] to allow the platform-specific parts of the
+standard library be documented.
+
+```rust
+#![feature(doc_cfg)]
+
+#[cfg(any(windows, feature = "documentation"))]
+#[doc(cfg(windows))]
+/// The application's icon in the notification area (a.k.a. system tray).
+///
+/// # Examples
+///
+/// ```no_run
+/// extern crate my_awesome_ui_library;
+/// use my_awesome_ui_library::current_app;
+/// use my_awesome_ui_library::windows::notification;
+///
+/// let icon = current_app().get::<notification::Icon>();
+/// icon.show();
+/// icon.show_message("Hello");
+/// ```
+pub struct Icon {
+    // ...
+}
+```
+
+[#43781]: https://github.com/rust-lang/rust/issues/43781
+[#43348]: https://github.com/rust-lang/rust/issues/43348
\ No newline at end of file