Skip to content

Commit

Permalink
Add tests for no-hidden-lines codeblock attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Dec 10, 2023
1 parent 5920cb9 commit 2ba9f45
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<code><span class="macro">macro_rules! </span>test {
(# a,##b,###c) =&gt; {}
}

<span class="macro">test!</span>(
#b,
##c
);</code>
9 changes: 9 additions & 0 deletions tests/rustdoc/no-hidden-lines-codeblock-format.codeblock.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<code><span class="macro">macro_rules! </span>test {
(# a,##b,###c) =&gt; {}
}

<span class="macro">test!</span>(
# a,
##b,
###c
);</code>
54 changes: 54 additions & 0 deletions tests/rustdoc/no-hidden-lines-codeblock-format.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Test that the `no_hidden_lines` codeblock attribute prevents lines starting with `#` to
// be stripped.

#![crate_name = "foo"]

// @has 'foo/index.html'
// @matches - '//*[@class="rust rust-example-rendered"]/code' '\(\s+# a,\s+##b,\s+###c\s+\);'
// @snapshot 'codeblock' - '//*[@class="rust rust-example-rendered"]/code'

//! ```rust,no_hidden_lines
//! macro_rules! test {
//! (# a,##b,###c) => {}
//! }
//!
//! test!(
//! # a,
//! ##b,
//! ###c
//! );
//! ```
// @has 'foo/fn.foo.html'
// @matches - '//*[@class="rust rust-example-rendered"]/code' '\(\s+#b,\s+##c\s+\);'
// @snapshot 'codeblock-non-raw' - '//*[@class="rust rust-example-rendered"]/code'

/// ```
/// macro_rules! test {
/// (# a,##b,###c) => {}
/// }
///
/// test!(
/// # a,
/// ##b,
/// ###c
/// );
/// ```
pub fn foo() {}

// Testing that `raw` means that it is a rust code block by default.
// @has 'foo/fn.bar.html'
// @matches - '//*[@class="rust rust-example-rendered"]/code' '\(\s+#a,\s+##b,\s+###c\s+\);'

/// ```no_hidden_lines
/// macro_rules! test {
/// (#a,##b,###c) => {}
/// }
///
/// test!(
/// #a,
/// ##b,
/// ###c
/// );
/// ```
pub fn bar() {}

0 comments on commit 2ba9f45

Please sign in to comment.