Skip to content

Commit 7a279d5

Browse files
committed
Update to ocamlformat 0.22.4
1 parent 5d0740a commit 7a279d5

File tree

7 files changed

+39
-57
lines changed

7 files changed

+39
-57
lines changed

.ocamlformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.17.0
1+
version=0.22.4

src/ast.ml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
are out of range. *)
99

1010
type 'a with_location = 'a Loc.with_location
11-
1211
type style = [ `Bold | `Italic | `Emphasis | `Superscript | `Subscript ]
1312

1413
type reference_kind = [ `Simple | `With_text ]
@@ -23,8 +22,7 @@ type inline_element =
2322
| `Reference of
2423
reference_kind * string with_location * inline_element with_location list
2524
| `Link of string * inline_element with_location list
26-
| `Math_span of string (** @since 2.0.0 *)
27-
]
25+
| `Math_span of string (** @since 2.0.0 *) ]
2826
(** Inline elements are equivalent to what would be found in a [span] in HTML.
2927
Mostly these are straightforward. The [`Reference] constructor takes a triple
3028
whose second element is the reference itself, and the third the replacement
@@ -43,7 +41,7 @@ type nestable_block_element =
4341
[ `Unordered | `Ordered ]
4442
* [ `Light | `Heavy ]
4543
* nestable_block_element with_location list list
46-
| `Math_block of string (** @since 2.0.0 *) ]
44+
| `Math_block of string (** @since 2.0.0 *) ]
4745
(** Some block elements may be nested within lists or tags, but not all.
4846
The [`List] constructor has a parameter of type [\[`Light | `Heavy\]].
4947
This corresponds to the syntactic constructor used (see the
@@ -71,7 +69,6 @@ type ocamldoc_tag =
7169
(** ocamldoc tags are those that are specified in the {{:https://ocaml.org/releases/4.12/htmlman/ocamldoc.html#ss:ocamldoc-tags}manual}) *)
7270

7371
type tag = [ ocamldoc_tag | internal_tag ]
74-
7572
type heading = int * string option * inline_element with_location list
7673

7774
type block_element =

src/loc.ml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
type point = { line : int; column : int }
2-
32
type span = { file : string; start : point; end_ : point }
4-
53
type +'a with_location = { location : span; value : 'a }
64

75
let at location value = { location; value }
8-
96
let location { location; _ } = location
10-
117
let value { value; _ } = value
12-
138
let map f annotated = { annotated with value = f annotated.value }
14-
159
let same annotated value = { annotated with value }
1610

1711
let span spans =

src/odoc_parser.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ type t = {
3030
[offset], relative to the beginning of a comment, into a location, relative
3131
to the beginning of the file containing the comment. This can then be used
3232
to convert from byte offset to line number / column number - a Loc.point,
33-
and additionally for converting back from a Loc.point to a Lexing.position.
34-
*)
33+
and additionally for converting back from a Loc.point to a Lexing.position.
34+
*)
3535

3636
let reversed_newlines : input:string -> (int * int) list =
3737
fun ~input ->
@@ -118,5 +118,4 @@ let parse_comment ~location ~text =
118118

119119
(* Accessor functions, as [t] is opaque *)
120120
let warnings t = t.warnings
121-
122121
let ast t = t.ast

src/syntax.ml

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ type input = {
2929
(* {2 Output} *)
3030

3131
let add_warning input warning = input.warnings := warning :: !(input.warnings)
32-
3332
let junk input = Stream.junk input.tokens
3433

3534
let peek input =
@@ -355,7 +354,8 @@ let paragraph : input -> Ast.nestable_block_element with_location =
355354
fun acc ->
356355
match npeek 2 input with
357356
| { value = `Single_newline ws; location }
358-
:: { value = #token_that_always_begins_an_inline_element; _ } :: _ ->
357+
:: { value = #token_that_always_begins_an_inline_element; _ }
358+
:: _ ->
359359
junk input;
360360
let acc = Loc.at location (`Space ws) :: acc in
361361
let acc = paragraph_line acc in
@@ -371,34 +371,34 @@ let paragraph : input -> Ast.nestable_block_element with_location =
371371
(* {3 Helper types} *)
372372

373373
(* The interpretation of tokens in the block parser depends on where on a line
374-
each token appears. The five possible "locations" are:
375-
376-
- [`At_start_of_line], when only whitespace has been read on the current
377-
line.
378-
- [`After_tag], when a valid tag token, such as [@deprecated], has been read,
379-
and only whitespace has been read since.
380-
- [`After_shorthand_bullet], when a valid shorthand list item bullet, such as
381-
[-], has been read, and only whitespace has been read since.
382-
- [`After_explicit_list_bullet], when a valid explicit bullet, such as [{li],
383-
has been read, and only whitespace has been read since.
384-
- [`After_text], when any other valid non-whitespace token has already been
385-
read on the current line.
386-
387-
Here are some examples of how this affects the interpretation of tokens:
388-
389-
- A paragraph can start anywhere except [`After_text] (two paragraphs cannot
390-
be on the same line, but paragraphs can be nested in just about anything).
391-
- [`Minus] is interpreted as a list item bullet [`At_start_of_line],
392-
[`After_tag], and [`After_explicit_list_bullet].
393-
- Tags are only allowed [`At_start_of_line].
394-
395-
To track the location accurately, the functions that make up the block parser
396-
pass explicit [where_in_line] values around and return them.
397-
398-
In a few cases, [where_in_line] can be inferred from what helper was called.
399-
For example, the [paragraph] parser always stops on the same line as the last
400-
significant token that is in the paragraph it consumed, so the location must
401-
be [`After_text]. *)
374+
each token appears. The five possible "locations" are:
375+
376+
- [`At_start_of_line], when only whitespace has been read on the current
377+
line.
378+
- [`After_tag], when a valid tag token, such as [@deprecated], has been read,
379+
and only whitespace has been read since.
380+
- [`After_shorthand_bullet], when a valid shorthand list item bullet, such as
381+
[-], has been read, and only whitespace has been read since.
382+
- [`After_explicit_list_bullet], when a valid explicit bullet, such as [{li],
383+
has been read, and only whitespace has been read since.
384+
- [`After_text], when any other valid non-whitespace token has already been
385+
read on the current line.
386+
387+
Here are some examples of how this affects the interpretation of tokens:
388+
389+
- A paragraph can start anywhere except [`After_text] (two paragraphs cannot
390+
be on the same line, but paragraphs can be nested in just about anything).
391+
- [`Minus] is interpreted as a list item bullet [`At_start_of_line],
392+
[`After_tag], and [`After_explicit_list_bullet].
393+
- Tags are only allowed [`At_start_of_line].
394+
395+
To track the location accurately, the functions that make up the block parser
396+
pass explicit [where_in_line] values around and return them.
397+
398+
In a few cases, [where_in_line] can be inferred from what helper was called.
399+
For example, the [paragraph] parser always stops on the same line as the last
400+
significant token that is in the paragraph it consumed, so the location must
401+
be [`After_text]. *)
402402
type where_in_line =
403403
[ `At_start_of_line
404404
| `After_tag
@@ -438,7 +438,6 @@ type stopped_implicitly =
438438

439439
(* Ensure that the above two types are really subsets of [Token.t]. *)
440440
let _check_subset : stops_at_delimiters -> Token.t = fun t -> (t :> Token.t)
441-
442441
let _check_subset : stopped_implicitly -> Token.t = fun t -> (t :> Token.t)
443442

444443
(* The different contexts in which the block parser [block_element_list] can be
@@ -907,8 +906,7 @@ let rec block_element_list :
907906
|> accepted_in_all_contexts context
908907
|> Loc.at location
909908
in
910-
consume_block_elements ~parsed_a_tag `At_start_of_line
911-
(paragraph :: acc)
909+
consume_block_elements ~parsed_a_tag `At_start_of_line (paragraph :: acc)
912910
in
913911

914912
let where_in_line =
@@ -993,8 +991,7 @@ and explicit_list_items :
993991
let next_token = peek input in
994992
match next_token.value with
995993
| `End ->
996-
Parse_error.not_allowed next_token.location
997-
~what:(Token.describe `End)
994+
Parse_error.not_allowed next_token.location ~what:(Token.describe `End)
998995
~in_what:(Token.describe parent_markup)
999996
|> add_warning input;
1000997
(List.rev acc, next_token.location)
@@ -1043,8 +1040,7 @@ and explicit_list_items :
10431040
| `Right_brace -> junk input
10441041
| `End ->
10451042
Parse_error.not_allowed token_after_list_item.location
1046-
~what:(Token.describe `End)
1047-
~in_what:(Token.describe token)
1043+
~what:(Token.describe `End) ~in_what:(Token.describe token)
10481044
|> add_warning input);
10491045

10501046
let acc = content :: acc in
@@ -1092,7 +1088,7 @@ let parse warnings tokens =
10921088
in
10931089

10941090
junk input;
1095-
elements @ block :: parse_block_elements ()
1091+
elements @ (block :: parse_block_elements ())
10961092
in
10971093
let ast = parse_block_elements () in
10981094
(ast, List.rev !(input.warnings))

src/token.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
for error messages. *)
44

55
type section_heading = [ `Begin_section_heading of int * string option ]
6-
76
type style = [ `Bold | `Italic | `Emphasis | `Superscript | `Subscript ]
8-
97
type paragraph_style = [ `Left | `Center | `Right ]
108

119
type tag =

test/test.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ module Ast_to_sexp = struct
1919
type at = { at : 'a. ('a -> sexp) -> 'a Loc.with_location -> sexp }
2020

2121
let loc_at = { at = Location_to_sexp.at }
22-
2322
let str s = Atom s
24-
2523
let opt f s = match s with Some s -> List [ f s ] | None -> List []
2624

2725
let style : Ast.style -> sexp = function

0 commit comments

Comments
 (0)