Skip to content

Commit 6a0cdb0

Browse files
author
Joe Previte
committed
feat: add doc attributes section to documentation
1 parent c49ae9e commit 6a0cdb0

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/meta/doc.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Use `cargo test` to run all tests (including documentation tests), and `cargo te
66

77
These commands will appropriately invoke `rustdoc` (and `rustc`) as required.
88

9-
### Doc comments
9+
## Doc comments
1010

1111
Doc comments are very useful for big projects that require documentation. When
1212
running Rustdoc, these are the comments that get compiled into
@@ -65,6 +65,43 @@ $ rustc doc.rs --crate-type lib
6565
$ rustdoc --test --extern doc="libdoc.rlib" doc.rs
6666
```
6767

68+
## Doc attributes
69+
70+
Below are a few examples of the most common `#[doc]` attributes used with `rustdoc`.
71+
72+
### `inline`
73+
74+
Used to inline docs, instead of linking out to separate page.
75+
76+
```rust
77+
#[doc(inline)]
78+
pub use bar::Bar;
79+
80+
/// bar docs
81+
mod bar {
82+
/// the docs for Bar
83+
pub struct Bar;
84+
}
85+
```
86+
87+
### `no_inline`
88+
Used to prevent linking out to separate page or anywhere.
89+
90+
```rust
91+
// Example from libcore/prelude
92+
#[doc(no_inline)]
93+
pub use crate::mem::drop;
94+
```
95+
96+
### `hidden`
97+
98+
Using this tells `rustdoc` not to include this in documentation:
99+
```rust,editable
100+
// Example from the futures-rs library
101+
#[doc(hidden)]
102+
pub use self::async_await::*;
103+
```
104+
68105
### See also:
69106

70107
* [The Rust Book: Making Useful Documentation Comments][book]

0 commit comments

Comments
 (0)