Skip to content

Commit 5fbadfc

Browse files
rustdoc book: add #![doc(test(no_crate_inject))] and #![doc(test(attr(...)))]
1 parent dcd343b commit 5fbadfc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/doc/rustdoc/src/the-doc-attribute.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,26 @@ to it in the docs. But if you include this:
103103

104104
it will not.
105105

106+
### `test(no_crate_inject)`
107+
108+
By default, `rustdoc` will automatically add a line with `extern crate my_crate;` into each doctest.
109+
But if you include this:
110+
111+
```rust,ignore
112+
#![doc(test(no_crate_inject))]
113+
```
114+
115+
it will not.
116+
117+
### `test(attr(...))`
118+
119+
This form of the `doc` attribute allows you to add arbitrary attributes to all your doctests. For
120+
example, if you want your doctests to fail if they produce any warnings, you could add this:
121+
122+
```rust,ignore
123+
#![doc(test(attr(deny(warnings))))]
124+
```
125+
106126
## At the item level
107127

108128
These forms of the `#[doc]` attribute are used on individual items, to control how

0 commit comments

Comments
 (0)