You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These attributes suppress or un-suppress the `auto_cfg` behavior for a particular configuration predicate.
45
45
46
-
For example, `#[doc(cfg_hide(windows))]` could be used in newer versions of the [`windows` crate] to prevent the "this is supported on **windows** only" tag from being shown on every single item.
46
+
For example, `#[doc(auto_cfg(hide(windows)))]` could be used in newer versions of the [`windows` crate] to prevent the "this is supported on **windows** only" tag from being shown on every single item.
All of these attributes can be added to a module or to the crate root, and they will be inherited by the child items unless another attribute overrides it. This is why "opposite" attributes like `cfg_hide` and `cfg_show` are provided: they allow a child item to override its parent.
51
+
All of these attributes can be added to a module or to the crate root, and they will be inherited by the child items unless another attribute overrides it. This is why "opposite" attributes like `auto_cfg(hide(...))` and `auto_cfg(show(...))` are provided: they allow a child item to override its parent.
@@ -101,7 +101,7 @@ This attribute has the same syntax as conditional compilation, but it only cause
101
101
102
102
This attribute works on modules and on items.
103
103
104
-
### `#[doc(cfg_hide(...))]`
104
+
### `#[doc(auto_cfg(hide(...)))]`
105
105
106
106
This attribute is used to prevent some `cfg` to be generated in the visual markers. It only applies to `#[doc(auto_cfg = true)]`, not to `#[doc(cfg(...))]`. So in the previous example:
107
107
@@ -113,13 +113,13 @@ pub mod futures {}
113
113
It currently displays both `unix` and `feature = "futures-io"` into the documentation, which is not great. To prevent the `unix` cfg to ever be displayed, you can use this attribute at the crate root level:
114
114
115
115
```rust
116
-
#![doc(cfg_hide(unix))]
116
+
#![doc(auto_cfg(hide(unix)))]
117
117
```
118
118
119
119
Or directly on a given item/module as it covers any of the item's descendants:
120
120
121
121
```rust
122
-
#[doc(cfg_hide(unix))]
122
+
#[doc(auto_cfg(hide(unix)))]
123
123
#[cfg(any(unix, feature ="futures-io"))]
124
124
pubmodfutures {
125
125
// `futures` and all its descendants won't display "unix" in their cfgs.
@@ -133,37 +133,37 @@ Rustdoc currently hides `doc` and `doctest` attributes by default and reserves t
133
133
The attribute accepts only a list of identifiers or key/value items. So you can write:
If `cfg_show` and `cfg_hide` are used to show/hide a same `cfg` on a same item, it'll emit an error. Example:
146
+
If `cfg_auto(show(...))` and `cfg_auto(hide(...))` are used to show/hide a same `cfg` on a same item, it'll emit an error. Example:
147
147
148
148
```rust
149
-
#[doc(cfg_hide(unix))]
150
-
#[doc(cfg_show(unix))] // Error!
149
+
#[doc(auto_cfg(hide(unix)))]
150
+
#[doc(auto_cfg(show(unix)))] // Error!
151
151
pubfnfoo() {}
152
152
```
153
153
154
-
### `#[doc(cfg_show(...))]`
154
+
### `#[doc(auto_cfg(show(...)))]`
155
155
156
-
This attribute does the opposite of `#[doc(cfg_hide(...))]`: if you used `#[doc(cfg_hide(...))]` and want to revert its effect on an item and its descendants, you can use `#[doc(cfg_show(...))]`.
156
+
This attribute does the opposite of `#[doc(auto_cfg(hide(...)))]`: if you used `#[doc(auto_cfg(hide(...)))]` and want to revert its effect on an item and its descendants, you can use `#[doc(auto_cfg(show(...)))]`.
157
157
It only applies to `#[doc(auto_cfg = true)]`, not to `#[doc(cfg(...))]`.
158
158
159
159
For example:
160
160
161
161
```rust
162
-
#[doc(cfg_hide(unix))]
162
+
#[doc(auto_cfg(hide(unix)))]
163
163
#[cfg(any(unix, feature ="futures-io"))]
164
164
pubmodfutures {
165
165
// `futures` and all its descendants won't display "unix" in their cfgs.
166
-
#[doc(cfg_show(unix))]
166
+
#[doc(auto_cfg(show(unix)))]
167
167
pubmodchild {
168
168
// `child` and all its descendants will display "unix" in their cfgs.
169
169
}
@@ -173,21 +173,21 @@ pub mod futures {
173
173
The attribute accepts only a list of identifiers or key/value items. So you can write:
0 commit comments