@@ -452,21 +452,42 @@ val spellcheck : string list -> string -> string list
452
452
val aligned_hint :
453
453
prefix :string -> Format_doc .formatter ->
454
454
('a , Format_doc .formatter , unit , Format_doc .t option -> unit ) format4 -> 'a
455
- (* * [aligned_hint ppf fmt ... hint] align the right end of
456
- [@{<ralign>...@}] box in the main error message and the hint under the
457
- assumption that there is an implicit [prefix] before the main
458
- error message. *)
455
+ (* * [aligned_hint ~prefix ppf fmt ... hint] vertically aligns a main message
456
+ (described by the [fmt] format string) and a possible hint message. The
457
+ vertical alignment is controlled by the use of [@{<ralign> ... @}] boxes:
458
+ the start of one box, in either the hint or the main message, will be
459
+ shifted on the left to ensure that the end of the two boxes are vertically
460
+ aligned, taking in account a pre-existing [prefix] before the main message.
461
+ For instance, if you have already printed ["Error: "] at the beginning of
462
+ the current line
463
+
464
+ {[aligned_hint
465
+ ~prefix:"Error: " "@{<ralign>The value @}%a is not an instance variable"
466
+ Style.inline_code "foobar"
467
+ (Some(doc_printf
468
+ "@{<ralign>Did you mean @}%a" Style.inline_code "foobaz"
469
+ ))]}
470
+
471
+ produces the following text:
472
+
473
+ {[
474
+ Error: The value "foobaz" is not an instance variable
475
+ Hint: Did you mean "foobar"?
476
+ ]}
477
+
478
+ where the main message has been shifted to the left to align ["foobaz"] and
479
+ ["foobar"].
480
+ *)
459
481
460
482
val aligned_error_hint :
461
483
Format_doc .formatter ->
462
484
('a , Format_doc .formatter , unit , Format_doc .t option -> unit ) format4 -> 'a
463
485
(* * Same as [aligned_hint ~prefix:"Error: "] *)
464
486
465
487
val did_you_mean :
466
- ?pp : string Format_doc .printer ->
467
- string list -> Format_doc .t option
468
- (* * [did_you_mean ~align ~pp choices] hints that the user may have meant one of
469
- the option in [choices].
488
+ ?pp : string Format_doc .printer -> string list -> Format_doc .t option
489
+ (* * [did_you_mean ~pp choices] hints that the user may have meant one of the
490
+ option in [choices].
470
491
471
492
Each choice is printed with the [pp] function, or [Style.inline_code] if
472
493
[pp]=[None].
0 commit comments