@@ -106,27 +106,25 @@ The `#[doc(cfg(...))]` attribute has another effect: When Rustdoc renders docume
106106item, it will be accompanied by a banner explaining that the item is only available on certain
107107platforms.
108108
109- As mentioned earlier, getting the items to Rustdoc requires some extra preparation. The standard
110- library adds a ` --cfg dox ` flag to every Rustdoc command, but the same thing can be accomplished by
111- adding a feature to your Cargo.toml and adding ` --feature dox ` (or whatever you choose to name the
112- feature) to your ` cargo doc ` calls .
109+ For Rustdoc to document an item, it needs to see it, regardless of what platform it's currently
110+ running on. To aid this, Rustdoc sets the flag ` #[cfg(rustdoc)] ` when running on your crate.
111+ Combining this with the target platform of a given item allows it to appear when building your crate
112+ normally on that platform, as well as when building documentation anywhere .
113113
114- Either way, once you create an environment for the documentation, you can start to augment your
115- ` #[cfg] ` attributes to allow both the target platform * and* the documentation configuration to leave
116- the item in. For example, ` #[cfg(any(windows, feature = "dox"))] ` will preserve the item either on
117- Windows or during the documentation process. Then, adding a new attribute ` #[doc(cfg(windows))] `
118- will tell Rustdoc that the item is supposed to be used on Windows. For example:
114+ For example, ` #[cfg(any(windows, rustdoc))] ` will preserve the item either on Windows or during the
115+ documentation process. Then, adding a new attribute ` #[doc(cfg(windows))] ` will tell Rustdoc that
116+ the item is supposed to be used on Windows. For example:
119117
120118``` rust
121119#![feature(doc_cfg)]
122120
123121/// Token struct that can only be used on Windows.
124- #[cfg(any(windows, feature = " dox " ))]
122+ #[cfg(any(windows, rustdoc ))]
125123#[doc(cfg(windows))]
126124pub struct WindowsToken ;
127125
128126/// Token struct that can only be used on Unix.
129- #[cfg(any(unix, feature = " dox " ))]
127+ #[cfg(any(unix, rustdoc ))]
130128#[doc(cfg(unix))]
131129pub struct UnixToken ;
132130```
0 commit comments