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
Copy file name to clipboardExpand all lines: src/doc/rustdoc/src/unstable-features.md
+46-4Lines changed: 46 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -850,12 +850,49 @@ pub mod futures {
850
850
851
851
Then, the `unix` cfg will never be displayed into the documentation.
852
852
853
-
Rustdoc currently hides `doc` and `doctest` attributes by default and reserves the right to change the list of "hidden by default" attributes.
853
+
The syntax of `hide` is as follows: you can list as many `cfg` name as you want:
854
+
855
+
```rust,ignore (nightly)
856
+
#[doc(auto_cfg(hide(feature, target_os)))]
857
+
```
858
+
859
+
With the above example, it means that `#[cfg(feature)]` and `#[cfg(target_os)]` won't be displayed in the docs. However, `#[cfg(target_os = "linux)]` or `#[cfg(feature = "something")]` will be displayed because only the key without values was marked as hidden. if you want to hide some values, you can do:
In this case, `#[cfg(feature = "linux")]`, `#[cfg(feature = "something")]`, `#[cfg(target_os = "something")]` and `#[cfg(target_os = "linux")]` will be hidden. All listed keys will be impacted by `values()`. You can split them by having two `hide`:
866
+
867
+
```rust,ignore (nightly)
868
+
#[doc(auto_cfg(
869
+
hide(feature, values("something")),
870
+
hide(target_os, values("linux"))))]
871
+
```
872
+
873
+
Now, only `#[cfg(feature = "something")]` and `#[cfg(target_os = "linux")]` will be hidden. If you want to hide all values of a key, you can use `any()`:
874
+
875
+
```rust,ignore (nightly)
876
+
#[doc(auto_cfg(hide(feature, values(any()))))]
877
+
```
878
+
879
+
To be noted, if you have `values()`, it will be considered the same as `values(any())`. If you want to hide when there is no value (while also hiding values at the same time), you can use `none()`:
So if we use `doc(auto_cfg(hide(unix)))`, it means it will hide all mentions of `unix`:
905
+
So if we use `doc(auto_cfg(hide(unix)))`, it means it will hide all mentions of `unix` without a value:
869
906
870
907
```rust,ignore (nightly)
871
908
#[cfg(unix)] // nothing displayed
@@ -919,6 +956,8 @@ The reason behind this is that `doc(auto_cfg = ...)` enables or disables the fea
919
956
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(...)))]`.
920
957
It only applies to `#[doc(auto_cfg = true)]`, not to `#[doc(cfg(...))]`.
921
958
959
+
It follows the same syntax rules as for `#[doc(auto_cfg(hide(...)))]`.
960
+
922
961
For example:
923
962
924
963
```rust,ignore (nightly)
@@ -936,7 +975,10 @@ pub mod futures {
936
975
The attribute accepts only a list of identifiers or key/value items. So you can write:
0 commit comments