Skip to content

Commit 4395618

Browse files
authored
Rollup merge of #132876 - lolbinarycat:rustdoc-document-hidden-items, r=GuillaumeGomez
rustdoc book: acknowledge --document-hidden-items
2 parents 9f48ded + ff7533e commit 4395618

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

Diff for: src/doc/rustdoc/src/command-line-arguments.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ mod private { // this item is private and will not be documented
100100
}
101101
```
102102

103-
`--document-private-items` documents all items, even if they're not public.
103+
`--document-private-items` includes all non-public items in the generated documentation except for `#[doc(hidden)]` items. Private items will be shown with a 🔒 icon.
104+
104105

105106
## `-L`/`--library-path`: where to look for dependencies
106107

Diff for: src/doc/rustdoc/src/unstable-features.md

+19
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,25 @@ themselves marked as unstable. To use any of these options, pass `-Z unstable-op
262262
the flag in question to Rustdoc on the command-line. To do this from Cargo, you can either use the
263263
`RUSTDOCFLAGS` environment variable or the `cargo rustdoc` command.
264264

265+
### `--document-hidden-items`: Show items that are `#[doc(hidden)]`
266+
<span id="document-hidden-items"></span>
267+
268+
By default, `rustdoc` does not document items that are annotated with
269+
[`#[doc(hidden)]`](write-documentation/the-doc-attribute.html#hidden).
270+
271+
`--document-hidden-items` causes all items to be documented as if they did not have `#[doc(hidden)]`, except that hidden items will be shown with a 👻 icon.
272+
273+
Here is a table that fully describes which items are documented with each combination of `--document-hidden-items` and `--document-private-items`:
274+
275+
276+
| rustdoc flags | items that will be documented |
277+
|---------------------------------|---------------------------------------|
278+
| neither flag | only public items that are not hidden |
279+
| only `--document-hidden-items` | all public items |
280+
| only `--document-private-items` | all items that are not hidden |
281+
| both flags | all items |
282+
283+
265284
### `--markdown-before-content`: include rendered Markdown before the content
266285

267286
* Tracking issue: [#44027](https://github.com/rust-lang/rust/issues/44027)

Diff for: src/doc/rustdoc/src/write-documentation/the-doc-attribute.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,8 @@ If you want to know more about inlining rules, take a look at the
230230

231231
<span id="dochidden"></span>
232232

233-
Any item annotated with `#[doc(hidden)]` will not appear in the documentation, unless
234-
the `strip-hidden` pass is removed. Re-exported items where one of its ancestors has
235-
`#[doc(hidden)]` will be considered the same as private.
233+
Any item annotated with `#[doc(hidden)]` will not appear in the documentation,
234+
unless the [`--document-hidden-items`](../unstable-features.md#document-hidden-items) flag is used.
236235

237236
You can find more information in the [`re-exports` chapter](./re-exports.md).
238237

0 commit comments

Comments
 (0)