Skip to content

Commit 8681f9c

Browse files
JulowLeonidas-from-XIV
authored andcommitted
Fix printing of footer in mli blocks
1 parent 990c26e commit 8681f9c

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/block.ml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ let lstrip string =
131131

132132
let pp_contents ?syntax ppf t =
133133
match (syntax, t.contents) with
134-
| Some Syntax.Mli, [ _ ] -> Fmt.pf ppf "%s" (String.concat "\n" t.contents)
135-
| Some Syntax.Mli, _ ->
136-
Fmt.pf ppf "\n%a" (pp_lines syntax t) (List.map lstrip t.contents)
134+
| Some Syntax.Mli, [ line ] -> Fmt.pf ppf "%s" line
135+
| Some Syntax.Mli, lines ->
136+
Fmt.pf ppf "@\n%a@\n" (pp_lines syntax t) (List.map lstrip lines)
137137
| (Some Cram | Some Normal | None), [] -> ()
138138
| (Some Cram | Some Normal | None), _ ->
139139
Fmt.pf ppf "%a\n" (pp_lines syntax t) t.contents
@@ -146,10 +146,9 @@ let pp_errors ppf t =
146146
Fmt.string ppf "```\n"
147147
| _ -> ()
148148

149-
let pp_footer ?syntax ppf t =
149+
let pp_footer ?syntax ppf _ =
150150
match syntax with
151-
| Some Syntax.Mli ->
152-
if List.length t.contents = 1 then Fmt.pf ppf "" else Fmt.pf ppf "\n"
151+
| Some Syntax.Mli -> ()
153152
| Some Syntax.Cram -> ()
154153
| _ -> Fmt.string ppf "```\n"
155154

lib/test/mdx_test.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ let run_cram_tests ?syntax t ?root ppf temp_file pad tests =
118118
output;
119119
Cram.pp_exit_code ~pad ppf n)
120120
tests;
121-
match syntax with Some Syntax.Mli -> () | _ -> Block.pp_footer ?syntax ppf t
121+
Block.pp_footer ?syntax ppf t
122122

123123
let eval_test ?block ?root c cmd =
124124
Log.debug (fun l -> l "eval_test %a" Fmt.(Dump.list (Fmt.fmt "%S")) cmd);
@@ -197,7 +197,7 @@ let run_toplevel_tests ?syntax ?root c ppf tests t =
197197
Output.pp ~pad ppf (`Output line))
198198
output)
199199
tests;
200-
match syntax with Some Syntax.Mli -> () | _ -> Block.pp_footer ?syntax ppf t
200+
Block.pp_footer ?syntax ppf t
201201

202202
type file = { first : Mdx.Part.file; current : Mdx.Part.file }
203203

0 commit comments

Comments
 (0)