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
When this is turned on (with `doc(auto_cfg= true)`, `#[cfg]` attributes are shown in documentation just like `#[doc(cfg)]` attributes are. By default, `auto_cfg` will be enabled.
34
+
When this is turned on (with `doc(auto_cfg)` or `doc(auto_cfg = true)`), `#[cfg]` attributes are shown in documentation just like `#[doc(cfg)]` attributes are. By default, `auto_cfg` will be enabled.
35
35
36
36
*`#[doc(cfg(...))]`
37
37
@@ -43,7 +43,7 @@ This RFC proposes to add the following attributes:
43
43
44
44
These attributes suppress or un-suppress the `auto_cfg` behavior for a particular configuration predicate.
45
45
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.
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. Using these attributes will also re-enable `doc(auto_cfg)` if it was disabled at this location.
By default, `#[doc(auto_cfg)]` is enabled at the crate-level. When it's enabled, Rustdoc will automatically display `cfg(...)` compatibility information as-if the same `#[doc(cfg(...))]` had been specified.
61
61
@@ -72,6 +72,8 @@ There's no need to "duplicate" the `cfg` into a `doc(cfg())` to make Rustdoc dis
72
72
73
73
In some situations, the detailed conditional compilation rules used to implement the feature might not serve as good documentation (for example, the list of supported platforms might be very long, and it might be better to document them in one place). To turn it off, add the `#[doc(auto_cfg = false)]` attribute on the item.
74
74
75
+
If no argument is specified (ie `#[doc(auto_cfg)]`), it's the same as writing `#[doc(auto_cfg = true)]`.
76
+
75
77
### `#[doc(cfg(...))]`
76
78
77
79
This attribute provides a standardized format to override `#[cfg()]` attributes to document conditionally available items. Example:
@@ -151,6 +153,14 @@ If `cfg_auto(show(...))` and `cfg_auto(hide(...))` are used to show/hide a same
151
153
pubfnfoo() {}
152
154
```
153
155
156
+
Using this attribute will re-enable `auto_cfg` if it was disabled at this location:
157
+
158
+
```rust
159
+
#[doc(auto_cfg = false)] // Disabling `auto_cfg`
160
+
#[doc(auto_cfg(hide(unix)))] // `auto_cfg` is re-enabled.
161
+
pubfnfoo() {}
162
+
```
163
+
154
164
### `#[doc(auto_cfg(show(...)))]`
155
165
156
166
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(...)))]`.
@@ -186,8 +196,16 @@ But you cannot write:
186
196
If `auto_cfg(show(...))` and `auto_cfg(hide(...))` are used to show/hide a same `cfg` on a same item, it'll emit an error. Example:
187
197
188
198
```rust
189
-
#[doc(auto_cfg(hide(unix)))]
190
-
#[doc(auto_cfg(show(unix)))] // Error!
199
+
#[doc(auto_cfg(show(unix)))]
200
+
#[doc(auto_cfg(hide(unix)))] // Error!
201
+
pubfnfoo() {}
202
+
```
203
+
204
+
Using this attribute will re-enable `auto_cfg` if it was disabled at this location:
205
+
206
+
```rust
207
+
#[doc(auto_cfg = false)] // Disabling `auto_cfg`
208
+
#[doc(auto_cfg(show(unix)))] // `auto_cfg` is re-enabled.
0 commit comments