Skip to content

Commit 25061a1

Browse files
Add documentation for raw codeblock attribute
1 parent 66ac000 commit 25061a1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/doc/rustdoc/src/write-documentation/what-to-include.md

+27
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,33 @@ The example is the same on the doc page, but has that extra information
8585
available to anyone trying to use your crate. More about tests in the
8686
upcoming [Documentation tests] chapter.
8787

88+
In case you're writing documentation for a macro, it might be useful to use
89+
the `raw` attribute in order to prevent some `#` characters to be stripped:
90+
91+
``````rust
92+
//! ```rust,raw
93+
//!
94+
//! test!(
95+
//! #a,
96+
//! ##b,
97+
//! ###c
98+
//! );
99+
//! ```
100+
macro_rules! test {
101+
(#a,##b,###c) => {}
102+
}
103+
``````
104+
105+
Without using the `raw` attribute, the code example would look like this:
106+
107+
```text
108+
test!(
109+
#a,
110+
#b,
111+
##c
112+
);
113+
```
114+
88115
## What to Exclude
89116

90117
Certain parts of your public interface may be included by default in the output

0 commit comments

Comments
 (0)