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/write-documentation/re-exports.md
+19-2
Original file line number
Diff line number
Diff line change
@@ -111,18 +111,35 @@ pub use self::public_mod::Public;
111
111
With this code, even though `public_mod::Public` is public and present in the documentation, the
112
112
`Public` type will be present both at the crate root and in the `public_mod` module.
113
113
114
+
## Preventing inlining with `#[doc(no_inline)]`
115
+
116
+
On the opposite of the `#[doc(inline)]` attribute, if you want to prevent an item from being
117
+
inlined, you can use `#[doc(no_inline)]`:
118
+
119
+
```rust,ignore (inline)
120
+
pub mod public_mod {
121
+
pub struct Public;
122
+
}
123
+
124
+
#[doc(no_inline)]
125
+
pub use self::public_mod::Public;
126
+
```
127
+
128
+
In the generated documentation, you will see a re-export at the crate root and not the type
129
+
directly.
130
+
114
131
## Attributes
115
132
116
133
When an item is inlined, its doc comments and most of its attributes will be inlined along with it:
117
134
118
-
| Attribute | Inlined? | Notes
135
+
| Attribute | Is it inlined alongside its item? | Notes
119
136
|--|--|--
120
137
| `#[doc=""]` | Yes | Intra-doc links are resolved relative to where the doc comment is defined (`///` is syntax sugar for doc string attributes).
121
138
|`#[doc(cfg(..))]`| Yes |
122
139
| `#[deprecated]` | Yes | Intra-doc links are resolved relative to where the description is defined.
123
140
|`#[doc(alias="")]`| No |
124
141
|`#[doc(inline)]`| No |
125
142
|`#[doc(no_inline)]`| No |
126
-
| `#[doc(hidden)]` | Glob imports | For name-based imports (such as `use module::Item as ModuleItem`), hiding an item acts the same as making it private. Glob-based imports (such as `use module::*`), hidden items are not inlined.
143
+
| `#[doc(hidden)]` | Glob imports | For name-based imports (such as `use module::Item as ModuleItem`), hiding an item acts the same as making it private. For glob-based imports (such as `use module::*`), hidden items are not inlined.
127
144
128
145
All other attributes are inherited when inlined, so that the documentation matches the behavior if the inlined item was directly defined at the spot where it's shown.
0 commit comments