Skip to content

Commit 640cf59

Browse files
committed
review feedback
1 parent bc9e082 commit 640cf59

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
The `#[doc]` attribute lets you control various aspects of how `rustdoc` does
44
its job.
55

6-
The most basic job of `#[doc]` is to be the way that the text of the documentation
7-
is handled. That is, `///` is syntax sugar for `#[doc]`. This means that these two
6+
The most basic function of `#[doc]` is to handle the actual documentation
7+
text. That is, `///` is syntax sugar for `#[doc]`. This means that these two
88
are the same:
99

1010
```rust,ignore
1111
/// This is a doc comment.
12-
#[doc = "This is a doc comment."]
12+
#[doc = " This is a doc comment."]
1313
```
1414

15+
(Note the leading space in the attribute version.)
16+
1517
In most cases, `///` is easier to use than `#[doc]`. One case where the latter is easier is
1618
when generating documentation in macros; the `collapse-docs` pass will combine multiple
1719
`#[doc]` attributes into a single doc comment, letting you generate code like this:
@@ -22,7 +24,13 @@ when generating documentation in macros; the `collapse-docs` pass will combine m
2224
#[doc = "doc comment"]
2325
```
2426

25-
Which can feel more flexible.
27+
Which can feel more flexible. Note that this would generate this:
28+
29+
```rust,ignore
30+
#[doc = "This is\n a \ndoc comment"]
31+
```
32+
33+
but given that docs are rendered via Markdown, it will remove these newlines.
2634

2735
The `doc` attribute has more options though! These don't involve the text of
2836
the output, but instead, various aspects of the presentation of the output.

0 commit comments

Comments
 (0)