Skip to content

Commit 62af014

Browse files
committed
Better handling of error in fix for #1001
1 parent 2d7dd9e commit 62af014

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/document/generator.ml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ let tag tag t = O.span ~attr:tag t
2626
let label t =
2727
match t with
2828
| Odoc_model.Lang.TypeExpr.Label s -> tag "label" (O.txt s)
29-
| RawOptional _s ->
30-
tag "error" (O.txt "Error: RawOptional found during rendering")
31-
| Optional s -> tag "optlabel" (O.txt "?" ++ O.txt s)
29+
| Optional s | RawOptional s -> tag "optlabel" (O.txt "?" ++ O.txt s)
3230

3331
let type_var tv = tag "type-var" (O.txt tv)
3432

@@ -424,6 +422,16 @@ module Make (Syntax : SYNTAX) = struct
424422
(* ++ O.end_hv *)
425423
in
426424
if not needs_parentheses then res else enclose ~l:"(" res ~r:")"
425+
| Arrow (Some (RawOptional _ as lbl), _src, dst) ->
426+
let res =
427+
O.span
428+
(O.box_hv
429+
@@ label lbl ++ O.txt ":"
430+
++ tag "error" (O.txt "???")
431+
++ O.txt " " ++ Syntax.Type.arrow)
432+
++ O.sp ++ type_expr dst
433+
in
434+
if not needs_parentheses then res else enclose ~l:"(" res ~r:")"
427435
| Arrow (Some lbl, src, dst) ->
428436
let res =
429437
O.span
@@ -1089,6 +1097,13 @@ module Make (Syntax : SYNTAX) = struct
10891097
(type_expr ~needs_parentheses:true src
10901098
++ O.txt " " ++ Syntax.Type.arrow)
10911099
++ O.txt " " ++ class_decl dst
1100+
| Arrow (Some (RawOptional _ as lbl), _src, dst) ->
1101+
O.span
1102+
(O.box_hv
1103+
@@ label lbl ++ O.txt ":"
1104+
++ tag "error" (O.txt "???")
1105+
++ O.txt " " ++ Syntax.Type.arrow)
1106+
++ O.sp ++ class_decl dst
10921107
| Arrow (Some lbl, src, dst) ->
10931108
O.span
10941109
(label lbl ++ O.txt ":"

0 commit comments

Comments
 (0)