Skip to content

Commit 39f0b57

Browse files
authored
Merge pull request #161 from CraigFe/pp-skip
Modify 'pp' to respect the 'skip' label
2 parents 55f7d5f + 540c32b commit 39f0b57

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

bin/pp.ml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,18 @@ let run () file section =
3434
| Mdx.Section _ | Text _ -> ()
3535
| Block b ->
3636
let b = Mdx.Block.eval b in
37-
Log.debug (fun l -> l "pp: %a" Mdx.Block.dump b);
38-
let pp_lines = Fmt.(list ~sep:(unit "\n") string) in
39-
let contents = Mdx.Block.executable_contents b in
40-
match b.value with
41-
| Toplevel _ -> Fmt.pr "%a\n" pp_lines contents
42-
| OCaml ->
43-
Fmt.pr "%a\n%a\n"
44-
Mdx.Block.pp_line_directive (file, b.line)
45-
pp_lines contents
46-
| _ -> ()
37+
if not (Mdx.Block.skip b) then (
38+
Log.debug (fun l -> l "pp: %a" Mdx.Block.dump b);
39+
let pp_lines = Fmt.(list ~sep:(unit "\n") string) in
40+
let contents = Mdx.Block.executable_contents b in
41+
match b.value with
42+
| Toplevel _ -> Fmt.pr "%a\n" pp_lines contents
43+
| OCaml ->
44+
Fmt.pr "%a\n%a\n"
45+
Mdx.Block.pp_line_directive (file, b.line)
46+
pp_lines contents
47+
| _ -> ()
48+
)
4749
) t;
4850
0
4951

test/section.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,11 @@ let () = print_endline (string_of_int x)
4040
# print_endline "42";;
4141
42
4242
```
43+
44+
## Skipped blocks
45+
46+
This block should not be executed by the tests:
47+
48+
```ocaml skip
49+
let () = assert false
50+
```

test/section.md.expected

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,11 @@ let () = print_endline (string_of_int x)
5050
# print_endline "42";;
5151
42
5252
```
53+
54+
## Skipped blocks
55+
56+
This block should not be executed by the tests:
57+
58+
```ocaml skip
59+
let () = assert false
60+
```

0 commit comments

Comments
 (0)