|
1 | 1 | # Comments
|
2 | 2 |
|
| 3 | +r[comments.syntax] |
| 4 | + |
3 | 5 | > **<sup>Lexer</sup>**\
|
4 | 6 | > LINE_COMMENT :\
|
5 | 7 | > `//` (~\[`/` `!` `\n`] | `//`) ~`\n`<sup>\*</sup>\
|
|
34 | 36 |
|
35 | 37 | ## Non-doc comments
|
36 | 38 |
|
| 39 | +r[comments.normal] |
| 40 | + |
37 | 41 | Comments follow the general C++ style of line (`//`) and
|
38 | 42 | block (`/* ... */`) comment forms. Nested block comments are supported.
|
39 | 43 |
|
| 44 | +r[comments.normal.tokenization] |
40 | 45 | Non-doc comments are interpreted as a form of whitespace.
|
41 | 46 |
|
42 | 47 | ## Doc comments
|
43 | 48 |
|
| 49 | +r[comments.doc] |
| 50 | + |
| 51 | +r[comments.doc.syntax] |
44 | 52 | Line doc comments beginning with exactly _three_ slashes (`///`), and block
|
45 | 53 | doc comments (`/** ... */`), both outer doc comments, are interpreted as a
|
46 |
| -special syntax for [`doc` attributes]. That is, they are equivalent to writing |
| 54 | +special syntax for [`doc` attributes]. |
| 55 | + |
| 56 | +r[comments.doc.attributes] |
| 57 | +That is, they are equivalent to writing |
47 | 58 | `#[doc="..."]` around the body of the comment, i.e., `/// Foo` turns into
|
48 | 59 | `#[doc="Foo"]` and `/** Bar */` turns into `#[doc="Bar"]`. They must therefore
|
49 | 60 | appear before something that accepts an outer attribute.
|
50 | 61 |
|
| 62 | +r[comments.doc.inner-syntax] |
51 | 63 | Line comments beginning with `//!` and block comments `/*! ... */` are
|
52 | 64 | doc comments that apply to the parent of the comment, rather than the item
|
53 |
| -that follows. That is, they are equivalent to writing `#![doc="..."]` around |
| 65 | +that follows. |
| 66 | + |
| 67 | +r[comments.doc.inner-attributes] |
| 68 | +That is, they are equivalent to writing `#![doc="..."]` around |
54 | 69 | the body of the comment. `//!` comments are usually used to document
|
55 | 70 | modules that occupy a source file.
|
56 | 71 |
|
| 72 | +r[comments.doc.bare-crs] |
57 | 73 | The character `U+000D` (CR) is not allowed in doc comments.
|
58 | 74 |
|
59 | 75 | > **Note**: It is conventional for doc comments to contain Markdown, as expected by
|
|
0 commit comments