Skip to content

Commit 66ac000

Browse files
Add tests for "raw" codeblock attribute
1 parent c7193e0 commit 66ac000

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<code><span class="macro">macro_rules! </span>test {
2+
(#a,##b,###c) =&gt; {}
3+
}
4+
5+
<span class="macro">test!</span>(
6+
#a,
7+
#b,
8+
##c
9+
);</code>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<code><span class="macro">macro_rules! </span>test {
2+
(#a,##b,###c) =&gt; {}
3+
}
4+
5+
<span class="macro">test!</span>(
6+
#a,
7+
##b,
8+
###c
9+
);</code>

tests/rustdoc/raw-codeblock-format.rs

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Test that the `raw` codeblock attribute prevents lines starting with `#` to be stripped.
2+
3+
#![crate_name = "foo"]
4+
5+
// @has 'foo/index.html'
6+
// @matches - '//*[@class="rust rust-example-rendered"]/code' '\(\s+#a,\s+##b,\s+###c\s+\);'
7+
// @snapshot 'codeblock' - '//*[@class="rust rust-example-rendered"]/code'
8+
9+
//! ```rust,raw
10+
//! macro_rules! test {
11+
//! (#a,##b,###c) => {}
12+
//! }
13+
//!
14+
//! test!(
15+
//! #a,
16+
//! ##b,
17+
//! ###c
18+
//! );
19+
//! ```
20+
21+
// @has 'foo/fn.foo.html'
22+
// @matches - '//*[@class="rust rust-example-rendered"]/code' '\(\s+#a,\s+#b,\s+##c\s+\);'
23+
// @snapshot 'codeblock-non-raw' - '//*[@class="rust rust-example-rendered"]/code'
24+
25+
/// ```
26+
/// macro_rules! test {
27+
/// (#a,##b,###c) => {}
28+
/// }
29+
///
30+
/// test!(
31+
/// #a,
32+
/// ##b,
33+
/// ###c
34+
/// );
35+
/// ```
36+
pub fn foo() {}
37+
38+
// Testing that `raw` means that it is a rust code block by default.
39+
// @has 'foo/fn.bar.html'
40+
// @matches - '//*[@class="rust rust-example-rendered"]/code' '\(\s+#a,\s+##b,\s+###c\s+\);'
41+
42+
/// ```raw
43+
/// macro_rules! test {
44+
/// (#a,##b,###c) => {}
45+
/// }
46+
///
47+
/// test!(
48+
/// #a,
49+
/// ##b,
50+
/// ###c
51+
/// );
52+
/// ```
53+
pub fn bar() {}

0 commit comments

Comments
 (0)