3 The features listed on this page fall outside the rest of the main categories.
5 ## `#[cfg(doc)]`: Documenting platform-/feature-specific information
7 For conditional compilation, Rustdoc treats your crate the same way the compiler does. Only things
8 from the host target are available (or from the given `--target` if present), and everything else is
9 "filtered out" from the crate. This can cause problems if your crate is providing different things
10 on different targets and you want your documentation to reflect all the available items you
13 If you want to make sure an item is seen by Rustdoc regardless of what platform it's targeting,
14 you can apply `#[cfg(doc)]` to it. Rustdoc sets this whenever it's building documentation, so
15 anything that uses that flag will make it into documentation it generates. To apply this to an item
16 with other `#[cfg]` filters on it, you can write something like `#[cfg(any(windows, doc))]`.
17 This will preserve the item either when built normally on Windows, or when being documented
20 Please note that this feature is not passed to doctests.
25 /// Token struct that can only be used on Windows.
26 #[cfg(any(windows, doc))]
27 pub struct WindowsToken;
28 /// Token struct that can only be used on Unix.
29 #[cfg(any(unix, doc))]
33 Here, the respective tokens can only be used by dependent crates on their respective platforms, but
34 they will both appear in documentation.
36 ## Add aliases for an item in documentation search
38 This feature allows you to add alias(es) to an item when using the `rustdoc` search through the
39 `doc(alias)` attribute. Example:
47 Then, when looking for it through the `rustdoc` search, if you enter "x" or
48 "big", search will show the `BigX` struct first.
50 There are some limitations on the doc alias names though: you can't use `"` or whitespace.