-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #43348 - kennytm:fix-24658-doc-every-platform, r=alexcr…
…ichton Expose all OS-specific modules in libstd doc. 1. Uses the special `--cfg dox` configuration passed by rustbuild when running `rustdoc`. Changes the `#[cfg(platform)]` into `#[cfg(any(dox, platform))]` so that platform-specific API are visible to rustdoc. 2. Since platform-specific implementations often won't compile correctly on other platforms, `rustdoc` is changed to apply `everybody_loops` to the functions during documentation and doc-test harness. 3. Since platform-specific code are documented on all platforms now, it could confuse users who found a useful API but is non-portable. Also, their examples will be doc-tested, so must be excluded when not testing on the native platform. An undocumented attribute `#[doc(cfg(...))]` is introduced to serve the above purposed. Fixes #24658 (Does _not_ fully implement #1998).
- Loading branch information
Showing
23 changed files
with
1,261 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.