Skip to content

Commit

Permalink
Autoreview comments
Browse files Browse the repository at this point in the history
- Remove now unused added utils function
- Simplified some code
- Removed formatting changes in otherwise unchanged cppo-ed files
- promote mdx tests

Signed-off-by: Paul-Elliot <[email protected]>
  • Loading branch information
panglesd committed Oct 26, 2023
1 parent c3aef88 commit a3e7601
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 31 deletions.
8 changes: 0 additions & 8 deletions src/document/utils.ml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
let option_of_result = function Result.Ok x -> Some x | Result.Error _ -> None

let filter_map f =
let rec aux accu = function
| [] -> List.rev accu
| x :: l -> (
match f x with None -> aux accu l | Some v -> aux (v :: accu) l)
in
aux []

let rec flatmap ?sep ~f = function
| [] -> []
| [ x ] -> f x
Expand Down
1 change: 0 additions & 1 deletion src/document/utils.mli
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
val filter_map : ('a -> 'b option) -> 'a list -> 'b list
val option_of_result : ('a, 'b) Result.result -> 'a option
val flatmap : ?sep:'a list -> f:('b -> 'a list) -> 'b list -> 'a list
val skip_until : p:('a -> bool) -> 'a list -> 'a list
Expand Down
10 changes: 3 additions & 7 deletions src/html/html_page.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@ let html_of_search () =
div ~a:[ a_class [ "search-inner" ] ] [ search_bar; snake; search_result ])

let sidebar toc =
let toc, has_toc =
match toc with
| [] -> ([], false)
| _ ->
([ Html.nav ~a:[ Html.a_class [ "odoc-toc" ] ] (html_of_toc toc) ], true)
in
if has_toc then toc else []
match toc with
| [] -> []
| _ -> [ Html.nav ~a:[ Html.a_class [ "odoc-toc" ] ] (html_of_toc toc) ]

let html_of_breadcrumbs (breadcrumbs : Types.breadcrumb list) =
let make_navigation ~up_url rest =
Expand Down
4 changes: 2 additions & 2 deletions src/loader/odoc_loader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ let read_cmt ~make_root ~parent ~filename ~source_id_opt () =
in
let content = Odoc_model.Lang.Compilation_unit.Pack items in
make_compilation_unit ~make_root ~imports ~interface ~sourcefile ~name
~id ~source_info:None content
~id ~source_info:None content
| Implementation impl ->
let id, sg, canonical = Cmt.read_implementation parent name impl in
let shape_info, source_info =
read_cmt_infos source_id_opt id ~filename ()
in
compilation_unit_of_sig ~make_root ~imports ~interface ~sourcefile
~name ~id ?canonical ?shape_info ~source_info sg
~name ~id ?canonical ?shape_info ~source_info sg
| _ -> raise Not_an_implementation)

let read_cmi ~make_root ~parent ~filename () =
Expand Down
26 changes: 13 additions & 13 deletions test/xref2/resolve/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Simplest possible resolution:
representation = None})];
compiled = true; doc = []};
expansion = None; linked = false; canonical = None; source_info = None;
shape_info = None; search_assets = []}
shape_info = None}
```

Let's look at a marginally more complicated example. In this case, our type `t`
Expand Down Expand Up @@ -318,7 +318,7 @@ Basic resolution 2, environment lookup:
representation = None})];
compiled = true; doc = []};
expansion = None; linked = false; canonical = None; source_info = None;
shape_info = None; search_assets = []}
shape_info = None}
```


Expand Down Expand Up @@ -521,7 +521,7 @@ Basic resolution 3, module type:
...];
compiled = ...; doc = ...};
expansion = ...; linked = ...; canonical = ...; source_info = ...;
shape_info = ...; search_assets = ...}
shape_info = ...}
```

This example is very similar but there is one more level of nesting of the modules:
Expand Down Expand Up @@ -724,7 +724,7 @@ Basic resolution 4, module type:
...];
compiled = ...; doc = ...};
expansion = ...; linked = ...; canonical = ...; source_info = ...;
shape_info = ...; search_assets = ...}
shape_info = ...}
```

This example is rather more interesting:
Expand Down Expand Up @@ -960,7 +960,7 @@ and then we can look up the type `t`.
...];
compiled = ...; doc = ...};
expansion = ...; linked = ...; canonical = ...; source_info = ...;
shape_info = ...; search_assets = ...}
shape_info = ...}
```

```ocaml
Expand Down Expand Up @@ -1167,7 +1167,7 @@ and then we can look up the type `t`.
...];
compiled = ...; doc = ...};
expansion = ...; linked = ...; canonical = ...; source_info = ...;
shape_info = ...; search_assets = ...}
shape_info = ...}
```

Ensure a substitution is taken into account during resolution:
Expand Down Expand Up @@ -1350,7 +1350,7 @@ Ensure a substitution is taken into account during resolution:
...];
compiled = ...; doc = ...};
expansion = ...; linked = ...; canonical = ...; source_info = ...;
shape_info = ...; search_assets = ...}
shape_info = ...}
```

Ensure a destructive substitution is taken into account during resolution:
Expand Down Expand Up @@ -1533,7 +1533,7 @@ Ensure a destructive substitution is taken into account during resolution:
...];
compiled = ...; doc = ...};
expansion = ...; linked = ...; canonical = ...; source_info = ...;
shape_info = ...; search_assets = ...}
shape_info = ...}
```

Resolve a module alias:
Expand Down Expand Up @@ -1694,7 +1694,7 @@ Resolve a module alias:
representation = None})];
compiled = true; doc = ...};
expansion = ...; linked = ...; canonical = ...; source_info = ...;
shape_info = ...; search_assets = ...}
shape_info = ...}
```

Resolve a module alias:
Expand Down Expand Up @@ -1854,7 +1854,7 @@ Resolve a module alias:
...];
compiled = ...; doc = ...};
expansion = ...; linked = ...; canonical = ...; source_info = ...;
shape_info = ...; search_assets = ...}
shape_info = ...}
```

Resolve a functor:
Expand Down Expand Up @@ -2036,7 +2036,7 @@ Resolve a functor:
...];
compiled = ...; doc = ...};
expansion = ...; linked = ...; canonical = ...; source_info = ...;
shape_info = ...; search_assets = ...}
shape_info = ...}
```

Resolve a functor:
Expand Down Expand Up @@ -2243,7 +2243,7 @@ Resolve a functor:
...];
compiled = ...; doc = ...};
expansion = ...; linked = ...; canonical = ...; source_info = ...;
shape_info = ...; search_assets = ...}
shape_info = ...}
```

```ocaml skip
Expand Down Expand Up @@ -2460,5 +2460,5 @@ Functor app nightmare:
...];
compiled = ...; doc = ...};
expansion = ...; linked = ...; canonical = ...; source_info = ...;
shape_info = ...; search_assets = ...}
shape_info = ...}
```

0 comments on commit a3e7601

Please sign in to comment.