this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix trailing code blocks in type definitions

Properly handle trailing code items (like closing brackets for
polymorphic variants) by appending them to the unified code block.

Cherry-picked from jonludlam/odoc@55fea14a2

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+17 -18
+14 -3
src/markdown2/generator.ml
··· 345 345 String.trim initial_code :: constructor_lines 346 346 in 347 347 let combined_lines = combine_code_with_docs initial_code l in 348 - if combined_lines <> [] then 349 - let combined_code = String.concat ~sep:"\n" combined_lines in 348 + (* Also collect any trailing Code items (like closing ']' for polymorphic variants) *) 349 + let rec collect_trailing_code items acc = 350 + match items with 351 + | (Code _ | Alternative _) :: _ -> 352 + let code, _, remaining = take_code items in 353 + let trailing_code = String.concat ~sep:"" (source inline_text_only code) in 354 + collect_trailing_code remaining (String.trim trailing_code :: acc) 355 + | rest -> (List.rev acc, rest) 356 + in 357 + let trailing_codes, final_rest = collect_trailing_code remaining_rest [] in 358 + let all_lines = combined_lines @ trailing_codes in 359 + if all_lines <> [] then 360 + let combined_code = String.concat ~sep:"\n" all_lines in 350 361 let code_block = Renderer.Block.Code_block { info_string; code = [combined_code] } in 351 - [code_block] @ to_markdown remaining_rest 362 + [code_block] @ to_markdown final_rest 352 363 else 353 364 let code = [ initial_code ] in 354 365 let block = Renderer.Block.Code_block { info_string; code } in
-6
test/markdown/adt_constructors.t/run.t
··· 66 66 | Gradient of Colors.color * Colors.color (** Gradient between two colors *) 67 67 | Pattern of Colors.color list (** Pattern of multiple colors *) 68 68 | Custom of string * int * int * int (** Custom color with name and RGB values *) 69 - ``` 70 - ``` 71 69 72 70 ``` 73 71 A color type with many variants representing different colors and color properties. ··· 79 77 | Normal (** Normal brightness *) 80 78 | Light (** Light variant *) 81 79 | VeryLight (** Very light variant *) 82 - ``` 83 - ``` 84 80 85 81 ``` 86 82 Brightness levels for colors. ··· 92 88 | Neutral (** Neutral temperature *) 93 89 | Cool (** Cool colors *) 94 90 | VeryCool (** Very cool colors (blues, purples) *) 95 - ``` 96 - ``` 97 91 98 92 ``` 99 93 Color temperature classification.
+3 -9
test/markdown/polymorphic_variants.t/run.t
··· 21 21 | `Purple (** Purple color *) 22 22 | `RGB of int * int * int (** RGB values *) 23 23 | `Named of string (** Named color *) 24 - ``` 25 - ``` 26 - ] 24 + ] 27 25 ``` 28 26 A polymorphic variant type with many constructors. 29 27 ··· 31 29 type status = [ 32 30 | `Active 33 31 | `Inactive of string 34 - ``` 35 - ``` 36 - ] 32 + ] 37 33 ``` 38 34 Simple fixed polymorphic variant. 39 35 ··· 42 38 | `A 43 39 | `B 44 40 | `C 45 - ``` 46 - ``` 47 - ] 41 + ] 48 42 ``` 49 43 Another simple polymorphic variant.