From a3e7601b2a2203a083a20e07781423e4dcc1c7b2 Mon Sep 17 00:00:00 2001 From: Paul-Elliot Date: Thu, 26 Oct 2023 10:55:06 +0200 Subject: [PATCH] Autoreview comments - 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 --- src/document/utils.ml | 8 -------- src/document/utils.mli | 1 - src/html/html_page.ml | 10 +++------- src/loader/odoc_loader.ml | 4 ++-- test/xref2/resolve/test.md | 26 +++++++++++++------------- 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/document/utils.ml b/src/document/utils.ml index 69d6311f2a..e3b5d861e4 100644 --- a/src/document/utils.ml +++ b/src/document/utils.ml @@ -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 diff --git a/src/document/utils.mli b/src/document/utils.mli index a8d1aff429..4ead7e29aa 100644 --- a/src/document/utils.mli +++ b/src/document/utils.mli @@ -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 diff --git a/src/html/html_page.ml b/src/html/html_page.ml index bba824ee2d..c55a89eb6c 100644 --- a/src/html/html_page.ml +++ b/src/html/html_page.ml @@ -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 = diff --git a/src/loader/odoc_loader.ml b/src/loader/odoc_loader.ml index 236de05d70..a3f0cb8799 100644 --- a/src/loader/odoc_loader.ml +++ b/src/loader/odoc_loader.ml @@ -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 () = diff --git a/test/xref2/resolve/test.md b/test/xref2/resolve/test.md index 07f252835e..741a3ed4aa 100644 --- a/test/xref2/resolve/test.md +++ b/test/xref2/resolve/test.md @@ -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` @@ -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} ``` @@ -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: @@ -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: @@ -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 @@ -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: @@ -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: @@ -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: @@ -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: @@ -1854,7 +1854,7 @@ Resolve a module alias: ...]; compiled = ...; doc = ...}; expansion = ...; linked = ...; canonical = ...; source_info = ...; - shape_info = ...; search_assets = ...} + shape_info = ...} ``` Resolve a functor: @@ -2036,7 +2036,7 @@ Resolve a functor: ...]; compiled = ...; doc = ...}; expansion = ...; linked = ...; canonical = ...; source_info = ...; - shape_info = ...; search_assets = ...} + shape_info = ...} ``` Resolve a functor: @@ -2243,7 +2243,7 @@ Resolve a functor: ...]; compiled = ...; doc = ...}; expansion = ...; linked = ...; canonical = ...; source_info = ...; - shape_info = ...; search_assets = ...} + shape_info = ...} ``` ```ocaml skip @@ -2460,5 +2460,5 @@ Functor app nightmare: ...]; compiled = ...; doc = ...}; expansion = ...; linked = ...; canonical = ...; source_info = ...; - shape_info = ...; search_assets = ...} + shape_info = ...} ```