Skip to content

Commit c989304

Browse files
Add documentation for no-hidden-lines codeblock attribute
1 parent 2ba9f45 commit c989304

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

+28
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,34 @@ 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 `no-hidden-lines` attribute in order to prevent some `#` characters to be
90+
stripped:
91+
92+
``````rust
93+
//! ```rust,no-hidden-lines
94+
//!
95+
//! test!(
96+
//! # a,
97+
//! ##b,
98+
//! ###c
99+
//! );
100+
//! ```
101+
macro_rules! test {
102+
(# a,##b,###c) => {}
103+
}
104+
``````
105+
106+
Without using the `no-hidden-lines` attribute, the generated code example would
107+
look like this:
108+
109+
```text
110+
test!(
111+
#b,
112+
##c
113+
);
114+
```
115+
88116
## What to Exclude
89117

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

0 commit comments

Comments
 (0)