Skip to content

Commit a928b00

Browse files
authored
Merge pull request #1602 from GKFX/invalid-block-docs
Document limitations on block doc comments
2 parents be0e8d4 + 42d3c9f commit a928b00

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/comments.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ Line doc comments beginning with exactly _three_ slashes (`///`), and block
4545
doc comments (`/** ... */`), both outer doc comments, are interpreted as a
4646
special syntax for [`doc` attributes]. That is, they are equivalent to writing
4747
`#[doc="..."]` around the body of the comment, i.e., `/// Foo` turns into
48-
`#[doc="Foo"]` and `/** Bar */` turns into `#[doc="Bar"]`.
48+
`#[doc="Foo"]` and `/** Bar */` turns into `#[doc="Bar"]`. They must therefore
49+
appear before something that accepts an outer attribute.
4950

5051
Line comments beginning with `//!` and block comments `/*! ... */` are
5152
doc comments that apply to the parent of the comment, rather than the item
@@ -55,6 +56,12 @@ modules that occupy a source file.
5556

5657
The character `U+000D` (CR) is not allowed in doc comments.
5758

59+
> **Note**: It is conventional for doc comments to contain Markdown, as expected by
60+
> `rustdoc`. However, the comment syntax does not respect any internal Markdown.
61+
> ``/** `glob = "*/*.rs";` */`` terminates the comment at the first `*/`, and the
62+
> remaining code would cause a syntax error. This slightly limits the content of
63+
> block doc comments compared to line doc comments.
64+
5865
> **Note**: The sequence `U+000D` (CR) immediately followed by `U+000A` (LF) would have been previously transformed into a single `U+000A` (LF).
5966
6067
## Examples

0 commit comments

Comments
 (0)