Skip to content

Commit 3c1dd4d

Browse files
committed
Add code (indentation) block tests
1 parent 4cc1f1f commit 3c1dd4d

File tree

4 files changed

+208
-0
lines changed

4 files changed

+208
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "Test"
3+
edition = "2024"
4+
5+
[dependencies]
6+
MoveStdlib = { local = "../../../../move-stdlib/", addr_subst = { "std" = "0x1" } }
7+
8+
[addresses]
9+
a = "0x42"
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
source: crates/move-docgen-tests/tests/testsuite.rs
3+
assertion_line: 74
4+
info:
5+
section_level_start: 1
6+
exclude_private_fun: false
7+
exclude_impl: false
8+
toc_depth: 3
9+
no_collapsed_sections: true
10+
include_dep_diagrams: false
11+
include_call_diagrams: false
12+
---
13+
<a name="a_m"></a>
14+
15+
# Module `a::m`
16+
17+
18+
<a name="@Code_Block_Formatting_0"></a>
19+
20+
## Code Block Formatting
21+
22+
23+
Indented code inside a fenced block should be preserved:
24+
25+
```
26+
fun example() {
27+
let x = 1;
28+
if (x > 0) {
29+
let y = x + 1;
30+
};
31+
}
32+
```
33+
34+
Text after code block with a nested list:
35+
36+
- Item one
37+
- Nested item
38+
39+
40+
- [Code Block Formatting](#@Code_Block_Formatting_0)
41+
- [Function `with_code_blocks`](#a_m_with_code_blocks)
42+
43+
44+
<pre><code></code></pre>
45+
46+
47+
48+
<a name="a_m_with_code_blocks"></a>
49+
50+
## Function `with_code_blocks`
51+
52+
Function with code block in doc:
53+
54+
```
55+
let v = vector[1, 2, 3];
56+
let sum = 0;
57+
while (!vector::is_empty(&v)) {
58+
sum = sum + vector::pop_back(&mut v);
59+
};
60+
```
61+
62+
And indented code block:
63+
64+
```
65+
indented_block();
66+
```
67+
68+
69+
<pre><code><b>entry</b> <b>fun</b> <a href="../a/m.md#a_m_with_code_blocks">with_code_blocks</a>()
70+
</code></pre>
71+
72+
73+
74+
##### Implementation
75+
76+
77+
<pre><code><b>entry</b> <b>fun</b> <a href="../a/m.md#a_m_with_code_blocks">with_code_blocks</a>() { }
78+
</code></pre>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
source: crates/move-docgen-tests/tests/testsuite.rs
3+
assertion_line: 74
4+
info:
5+
section_level_start: 1
6+
exclude_private_fun: false
7+
exclude_impl: false
8+
toc_depth: 3
9+
no_collapsed_sections: false
10+
include_dep_diagrams: false
11+
include_call_diagrams: false
12+
---
13+
<a name="a_m"></a>
14+
15+
# Module `a::m`
16+
17+
18+
<a name="@Code_Block_Formatting_0"></a>
19+
20+
## Code Block Formatting
21+
22+
23+
Indented code inside a fenced block should be preserved:
24+
25+
```
26+
fun example() {
27+
let x = 1;
28+
if (x > 0) {
29+
let y = x + 1;
30+
};
31+
}
32+
```
33+
34+
Text after code block with a nested list:
35+
36+
- Item one
37+
- Nested item
38+
39+
40+
- [Code Block Formatting](#@Code_Block_Formatting_0)
41+
- [Function `with_code_blocks`](#a_m_with_code_blocks)
42+
43+
44+
<pre><code></code></pre>
45+
46+
47+
48+
<a name="a_m_with_code_blocks"></a>
49+
50+
## Function `with_code_blocks`
51+
52+
Function with code block in doc:
53+
54+
```
55+
let v = vector[1, 2, 3];
56+
let sum = 0;
57+
while (!vector::is_empty(&v)) {
58+
sum = sum + vector::pop_back(&mut v);
59+
};
60+
```
61+
62+
And indented code block:
63+
64+
```
65+
indented_block();
66+
```
67+
68+
69+
<pre><code><b>entry</b> <b>fun</b> <a href="../a/m.md#a_m_with_code_blocks">with_code_blocks</a>()
70+
</code></pre>
71+
72+
73+
74+
<details>
75+
<summary>Implementation</summary>
76+
77+
78+
<pre><code><b>entry</b> <b>fun</b> <a href="../a/m.md#a_m_with_code_blocks">with_code_blocks</a>() { }
79+
</code></pre>
80+
81+
82+
83+
</details>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) Mysten Labs, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
/// # Code Block Formatting
5+
///
6+
/// Indented code inside a fenced block should be preserved:
7+
///
8+
/// ```
9+
/// fun example() {
10+
/// let x = 1;
11+
/// if (x > 0) {
12+
/// let y = x + 1;
13+
/// };
14+
/// }
15+
/// ```
16+
///
17+
/// Text after code block with a nested list:
18+
///
19+
/// - Item one
20+
/// - Nested item
21+
module a::m {
22+
/// Function with code block in doc:
23+
///
24+
/// ```
25+
/// let v = vector[1, 2, 3];
26+
/// let sum = 0;
27+
/// while (!vector::is_empty(&v)) {
28+
/// sum = sum + vector::pop_back(&mut v);
29+
/// };
30+
/// ```
31+
///
32+
/// And indented code block:
33+
///
34+
/// ```
35+
/// indented_block();
36+
/// ```
37+
entry fun with_code_blocks() { }
38+
}

0 commit comments

Comments
 (0)