ocaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Refactor driver

Push logic out of Driver into Phases.

+171 -180
+1 -1
bin/docs/Forester_docs.ml
··· 20 20 init 21 21 |> Driver.force 22 22 [ 23 - Load_all_configured_dirs; 23 + Load_configured_dirs; 24 24 Parse_all; 25 25 Build_import_graph; 26 26 Expand_all;
+1 -1
lib/compiler/Action.ml
··· 14 14 | Plant_assets 15 15 | Plant_foreign 16 16 | Done 17 - | Load_all_configured_dirs 17 + | Load_configured_dirs 18 18 | Parse_all 19 19 | Expand_all 20 20 | Eval_all
+55 -125
lib/compiler/Driver.ml
··· 14 14 end 15 15 16 16 let update (action : Action.t) (forest : State.t) = 17 - let open Action in 18 17 let forest = State.update_history ~forest action in 19 - let env = forest.env in 20 18 match action with 21 19 | Quit e -> begin match e with Fail -> exit 1 | Finished -> exit 0 end 22 20 | Query q -> 23 21 let r = Forest.run_datalog_query forest.graphs q in 24 - (Query_results r, forest) 25 - | Query_results _ -> (Done, forest) 26 - | Report_errors (_, next_action) -> (next_action, forest) 27 - | Load_all_configured_dirs -> 28 - let errors, paths = Eio_util.paths_of_dirs ~env forest.config.trees in 29 - (* Config validation prevents errors from happening at this stage *) 30 - assert (List.is_empty errors); 31 - let () = 32 - let@ tree_dir = List.iter @~ paths in 33 - assert (Eio.Path.is_directory tree_dir); 34 - let@ tree = Seq.iter @~ Phases.load tree_dir in 35 - let lsp_uri = Tree.Loaded.uri tree in 36 - let uri = URI.of_lsp_uri ~base:forest.config.url lsp_uri in 37 - URI.Tbl.replace forest.resolver uri (Lsp.Uri.to_path lsp_uri); 38 - forest.={uri} <- Tree tree 39 - in 40 - (Parse_all, forest) 22 + Query_results r 23 + | Query_results _ -> Done 24 + | Report_errors (_, next_action) -> next_action 25 + | Load_configured_dirs -> 26 + Phases.load_configured_dirs ~forest; 27 + Parse_all 41 28 | Parse_all -> 42 - let errors, codes = Phases.parse forest in 43 - let () = 44 - let@ uri, code = List.iter @~ codes in 45 - forest.={uri} <- Tree code; 46 - forest.?{uri} <- [] 47 - in 48 - if List.length errors = 0 then 49 - assert (Seq.for_all Tree.is_parsed (URI.Tbl.to_seq_values forest.index)); 50 - let () = 51 - let@ uri, error = List.iter @~ errors in 52 - forest.?{uri} <- [Error.parse_error error] 53 - in 54 - ( report 55 - ~errors:(List.map (snd >>> Error.parse_error) errors) 56 - ~and_then:Build_import_graph, 57 - forest ) 29 + let errors = Phases.parse_all forest in 30 + report ~errors ~and_then:Build_import_graph 58 31 | Build_import_graph -> 59 32 let errors, import_graph = Phases.build_import_graph ~forest in 33 + forest.import_graph <- import_graph; 60 34 Logs.debug (fun m -> 61 35 m "import graph has %d vertices" (Forest_graph.nb_vertex import_graph)); 62 - (report ~errors ~and_then:Expand_all, {forest with import_graph}) 36 + report ~errors ~and_then:Expand_all 63 37 | Expand_all -> 64 38 Logs.debug (fun m -> m "expanding trees"); 65 39 let errors = Phases.expand_all forest in 66 - (report ~errors ~and_then:Eval_all, forest) 40 + report ~errors ~and_then:Eval_all 67 41 | Expand uri -> begin 68 - match Option.bind forest.={uri} Tree.to_code with 69 - | None -> assert false 70 - | Some code -> 71 - let result, errors = Phases.expand forest code in 72 - forest.={uri} <- Tree result; 73 - (report ~errors ~and_then:(Eval uri), forest) 42 + Option.fold forest.={uri} ~none:(assert false) ~some:begin fun tree -> 43 + match Tree.to_code tree with 44 + | None -> assert false 45 + | Some code -> 46 + let result, errors = Phases.expand forest code in 47 + forest.={uri} <- Tree result; 48 + report ~errors ~and_then:(Eval uri) 49 + end 74 50 end 75 51 | Eval_all -> 76 52 Logs.debug (fun m -> m "evaluating"); 77 - let errors, results = Phases.eval forest in 78 - let jobs = 79 - let@ Eval.{articles; jobs} = List.concat_map @~ results in 80 - let () = 81 - let@ article = List.iter @~ articles in 82 - State.plant_resource ~forest T.(Article article) 83 - in 84 - jobs 85 - in 86 - (report ~errors ~and_then:(Run_jobs jobs), forest) 87 - | Eval uri -> begin 88 - let jobs = Phases.eval_only uri forest in 89 - (Run_jobs jobs, forest) 90 - end 53 + let jobs, errors = Phases.eval forest in 54 + report ~errors ~and_then:(Run_jobs jobs) 55 + | Eval uri -> 56 + let errors, jobs = Phases.eval_only uri forest in 57 + report ~errors ~and_then:(Run_jobs jobs) 91 58 | Plant_assets -> 92 - (* TODO: We really only need to plant the assets that are referred to (look 93 - for calls to Asset_router.uri_of_asset).*) 94 - let errors, paths = Eio_util.paths_of_dirs ~env forest.config.assets in 95 - let paths = Dir_scanner.scan_asset_directories paths in 96 - Logs.debug (fun m -> m "planting %i assets" (Seq.length paths)); 97 - let module EP = Eio.Path in 98 - begin 99 - let@ path = Eio.Fiber.List.iter ~max_fibers:20 @~ List.of_seq paths in 100 - let content = EP.load path in 101 - let source_path = EP.native_exn path in 102 - match 103 - Asset_router.install ~config:forest.config ~source_path ~content 104 - with 105 - | Error _ -> failwith "handle asset router install failure" 106 - | Ok uri -> 107 - Logs.debug (fun m -> m "Installed %s at %a" source_path URI.pp uri); 108 - State.plant_resource ~forest (T.Asset {uri; content}) 109 - end; 110 - (report ~errors:(List.map Error.io_error errors) ~and_then:Done, forest) 59 + let () = Phases.plant_assets ~forest in 60 + Done 111 61 | Plant_foreign -> 112 62 Logs.debug (fun m -> m "Planting foreign forests"); 113 63 let errors = Phases.implant_foreign ~forest in 114 - (report ~errors ~and_then:Done, forest) 64 + report ~errors ~and_then:Done 115 65 | Run_jobs jobs -> 116 - Phases.run_jobs forest jobs; 117 - (Done, forest) 66 + let () = Phases.run_jobs forest jobs in 67 + Done 118 68 | Load_tree path -> 119 69 let doc = Imports.load_tree path in 120 70 let lsp_uri = Tree.Loaded.uri doc in 121 71 let uri = URI.of_lsp_uri ~base:forest.config.url lsp_uri in 122 72 forest.={uri} <- Tree doc; 123 - (Parse lsp_uri, forest) 73 + Parse lsp_uri 124 74 | Parse uri -> 125 75 Logs.debug (fun m -> m "Reparsing"); 126 76 let uri = URI.of_lsp_uri ~base:forest.config.url uri in 127 - begin match Option.bind forest.={uri} Tree.to_doc with 128 - | Some doc -> begin 129 - match Parse.parse_document doc with 130 - | Ok code -> 131 - forest.={uri} <- Tree code; 132 - forest.?{uri} <- []; 133 - Imports.fixup ~uri code forest; 134 - (Expand uri, forest) 135 - | Error parse_error -> 136 - let errors = [Error.parse_error parse_error] in 137 - forest.?{uri} <- errors; 138 - (report ~errors ~and_then:Done, forest) 139 - end 140 - | None -> ( 141 - match Imports.resolve_uri_to_code ~forest uri with 142 - | Ok code -> 143 - Imports.fixup ~uri code forest; 144 - forest.={uri} <- Tree code; 145 - (Expand uri, forest) 146 - | Error errors -> (Report_errors (errors, Expand uri), forest)) 147 - end 148 - | Done -> (Done, forest) 77 + Phases.parse forest uri 78 + | Done -> Done 149 79 150 80 let run_until_done a s : State.t = 151 81 let rec go action state = 152 - let new_action, new_state = update action state in 82 + let new_action = update action state in 153 83 match action with 154 84 | Quit Fail -> exit 1 155 85 | Quit Finished -> exit 0 156 - | Done -> new_state 157 - | _ -> go new_action new_state 86 + | Done -> state 87 + | _ -> go new_action state 158 88 in 159 89 go a s 160 90 ··· 169 99 |> plant_assets |> implant_foreign 170 100 in 171 101 let rec go action state = 172 - let new_action, new_state = update action state in 102 + let new_action = update action state in 173 103 match action with 174 104 | Quit Fail -> exit 1 175 105 | Quit Finished -> exit 0 176 - | Done -> new_state 106 + | Done -> state 177 107 | Report_errors (errors, _) -> 178 108 assert (List.length errors > 0); 179 109 Logs.debug (fun m -> m "got %d errors" (List.length errors)); 180 110 List.iter Error.print errors; 181 - if any_fatal errors then go (Quit Fail) new_state 182 - else go new_action new_state 183 - | _ -> go new_action new_state 111 + if any_fatal errors then go (Quit Fail) state else go new_action state 112 + | _ -> go new_action state 184 113 in 185 - go Load_all_configured_dirs init 114 + go Load_configured_dirs init 186 115 187 116 let language_server ~env ~config = 188 117 let init = State.make ~env ~config ~dev:true () in 189 118 let rec go action state = 190 - let new_action, new_state = update action state in 119 + let new_action = update action state in 191 120 match action with 192 121 | Quit Fail -> exit 1 193 122 | Quit Finished -> exit 0 194 - | Done -> new_state 195 - | _ -> go new_action new_state 123 + | Done -> state 124 + | _ -> go new_action state 196 125 in 197 - let _, state = update Plant_assets init in 126 + let _ = update Plant_assets init in 198 127 (* TODO: this ought to implant the foreign trees as well *) 199 - go Load_all_configured_dirs state 128 + go Load_configured_dirs init 200 129 201 130 let run_with_history a s = 202 131 let history = ref [] in 203 132 let rec go action state = 204 133 history := action :: !history; 205 134 match update action state with 206 - | new_action, new_state -> 207 - if action = Done then new_state 135 + | new_action -> 136 + if action = Done then state 208 137 else begin 209 - go new_action new_state 138 + go new_action state 210 139 end 211 140 in 212 141 let forest = go a s in ··· 216 145 let errors = ref [] in 217 146 let rec go action state = 218 147 match update action state with 219 - | new_action, new_state -> ( 148 + | new_action -> begin 220 149 match action with 221 - | Done -> new_state 150 + | Done -> state 222 151 | Report_errors (errs, _) -> begin 223 152 errors := errs @ !errors; 224 - go new_action new_state 153 + go new_action state 225 154 end 226 - | _ -> go new_action new_state) 155 + | _ -> go new_action state 156 + end 227 157 in 228 158 let forest = go a s in 229 159 (forest, List.rev !errors) ··· 233 163 match msgs with 234 164 | [] -> state 235 165 | msg :: remaining -> 236 - let _discard, new_state = update msg state in 237 - force remaining new_state 166 + let _discard = update msg state in 167 + force remaining state
+86 -22
lib/compiler/Phases.ml
··· 23 23 let load (tree_dir : Eio.Fs.dir_ty Eio.Path.t) = 24 24 Dir_scanner.scan_directory tree_dir |> Seq.map Imports.load_tree 25 25 26 - let parse (forest : State.t) = 27 - let trees = forest.index |> URI.Tbl.to_seq |> List.of_seq in 28 - let@ uri, result = 29 - List.partition_map 30 - @~ 31 - let@ uri, tree = List.filter_map @~ trees in 32 - match Tree.to_doc tree with 33 - | Some document -> Some (uri, Parse.parse_document document) 34 - | None -> None 26 + let load_configured_dirs ~(forest : State.t) = 27 + let errors, paths = 28 + Eio_util.paths_of_dirs ~env:forest.env forest.config.trees 35 29 in 36 - match result with Ok tree -> Right (uri, tree) | Error e -> Left (uri, e) 30 + (* Config validation prevents errors from happening at this stage *) 31 + assert (List.is_empty errors); 32 + let@ tree_dir = List.iter @~ paths in 33 + assert (Eio.Path.is_directory tree_dir); 34 + let@ tree = Seq.iter @~ load tree_dir in 35 + let lsp_uri = Tree.Loaded.uri tree in 36 + let uri = URI.of_lsp_uri ~base:forest.config.url lsp_uri in 37 + URI.Tbl.replace forest.resolver uri (Lsp.Uri.to_path lsp_uri); 38 + forest.={uri} <- Tree tree 39 + 40 + let parse (forest : State.t) uri = 41 + let open Action in 42 + Option.bind forest.={uri} Tree.to_doc 43 + |> Option.fold 44 + ~some:begin fun tree -> 45 + match Parse.parse_document tree with 46 + | Ok code -> 47 + forest.={uri} <- Tree code; 48 + forest.?{uri} <- []; 49 + Imports.fixup ~uri code forest; 50 + Expand uri 51 + | Error parse_error -> 52 + let errors = [Error.parse_error parse_error] in 53 + forest.?{uri} <- errors; 54 + report ~errors ~and_then:Done 55 + end 56 + ~none:begin match Imports.resolve_uri_to_code ~forest uri with 57 + | Ok code -> 58 + Imports.fixup ~uri code forest; 59 + forest.={uri} <- Tree code; 60 + Expand uri 61 + | Error errors -> report ~errors ~and_then:(Expand uri) 62 + end 63 + 64 + let parse_all (forest : State.t) = 65 + let@ uri, tree = List.filter_map @~ State.get_all_unparsed ~forest in 66 + match Parse.parse_document tree with 67 + | Ok tree -> begin 68 + forest.={uri} <- Tree tree; 69 + forest.?{uri} <- []; 70 + None 71 + end 72 + | Error error -> 73 + forest.?{uri} <- [Error.parse_error error]; 74 + Some (Error.parse_error error) 37 75 38 76 let reparse (doc : Lsp.Text_document.t) (forest : State.t) = 39 77 Logs.debug (fun m -> m "reparsing"); ··· 105 143 end 106 144 107 145 let eval (forest : State.t) = 108 - let expanded_trees = State.get_all_expanded ~forest |> List.of_seq in 109 - let errors, results = 110 - let@ uri, tree = List.partition_map @~ expanded_trees in 146 + let (articles, jobs), errors = 147 + let open List in 148 + Pair.map_fst (split >>> Pair.map concat concat) 149 + @@ Pair.map 150 + (filter_map (function 151 + | None -> None 152 + | Some Eval.{articles; jobs} -> Some (articles, jobs))) 153 + concat 154 + @@ split 155 + @@ 156 + let@ uri, tree = map @~ State.get_all_expanded ~forest in 111 157 let source_path = 112 158 if forest.dev then URI.Tbl.find_opt forest.resolver uri else None 113 159 in 114 - right Eval.(eval_tree ~config:forest.config ~source_path ~uri tree) 160 + Eval.(eval_tree ~config:forest.config ~source_path ~uri tree) 115 161 in 116 - let results, additional_errors = 117 - let organize = 118 - List.split >>> Pair.map (List.filter_map Fun.id) List.concat 119 - in 120 - organize results 162 + let () = 163 + let@ article = List.iter @~ articles in 164 + State.plant_resource ~forest T.(Article article) 121 165 in 122 - (additional_errors @ List.concat errors, results) 166 + (jobs, errors) 123 167 124 168 let eval_only (uri : URI.t) (forest : State.t) = 125 169 match forest.={uri} with ··· 136 180 in 137 181 forest.?{uri} <- errors; 138 182 match result with 139 - | None -> [] 183 + | None -> (errors, []) 140 184 | Some {articles; jobs} -> 141 185 let () = 142 186 let@ article = List.iter @~ articles in 143 187 State.plant_resource ~forest (Article article) 144 188 in 145 - jobs 189 + (errors, jobs) 146 190 end 147 191 end 192 + 193 + let plant_assets ~(forest : State.t) = 194 + (* TODO: We really only need to plant the assets that are referred to (look 195 + for calls to Asset_router.uri_of_asset).*) 196 + let errors, paths = 197 + Eio_util.paths_of_dirs ~env:forest.env forest.config.assets 198 + in 199 + (* Config validation prevents errors from happening at this stage *) 200 + assert (List.length errors = 0); 201 + let paths = Dir_scanner.scan_asset_directories paths in 202 + Logs.debug (fun m -> m "planting %i assets" (Seq.length paths)); 203 + let module EP = Eio.Path in 204 + let@ path = Eio.Fiber.List.iter ~max_fibers:20 @~ List.of_seq paths in 205 + let content = EP.load path in 206 + let source_path = EP.native_exn path in 207 + match Asset_router.install ~config:forest.config ~source_path ~content with 208 + | Error _ -> failwith "handle asset router install failure" 209 + | Ok uri -> 210 + Logs.debug (fun m -> m "Installed %s at %a" source_path URI.pp uri); 211 + State.plant_resource ~forest (T.Asset {uri; content}) 148 212 149 213 let implant ~(forest : State.t) (foreign : Config.foreign) = 150 214 let* path =
+10 -7
lib/compiler/State.ml
··· 22 22 index: Tree.t URI.Tbl.t; 23 23 diagnostics: Error.t list URI.Tbl.t; 24 24 graphs: (module Forest_graphs.S); 25 - import_graph: Forest_graph.t; 25 + mutable import_graph: Forest_graph.t; 26 26 dependency_cache: Cache.t; 27 27 resolver: string URI.Tbl.t; 28 28 search_index: Forester_search.Index.t; ··· 102 102 let to_seq state = URI.Tbl.to_seq state.index 103 103 104 104 let get_all_unparsed ~forest = 105 - forest.index |> URI.Tbl.to_seq_values |> Seq.filter is_unparsed 105 + forest.index |> URI.Tbl.to_seq 106 + |> Seq.filter_map (fun (uri, tree) -> 107 + match Tree.to_doc tree with Some doc -> Some (uri, doc) | _ -> None) 108 + |> List.of_seq 106 109 107 110 let get_all_code ~forest = 108 111 forest.index |> URI.Tbl.to_seq ··· 118 121 forest.index |> URI.Tbl.to_seq 119 122 |> Seq.filter_map (fun (uri, tree) -> 120 123 match to_syn tree with None -> None | Some tree -> Some (uri, tree)) 124 + |> List.of_seq 121 125 122 126 let get_all_unevaluated ~forest = 123 127 forest.index |> URI.Tbl.to_seq 124 128 |> Seq.filter_map (fun (uri, tree) -> 125 129 if is_unevaluated tree then Some (uri, tree) else None) 126 130 127 - let get_all_articles : t -> T.content T.article Seq.t = 128 - fun state -> state.index |> URI.Tbl.to_seq_values |> Seq.filter_map to_article 131 + let get_all_articles ~forest = 132 + forest.index |> URI.Tbl.to_seq_values |> Seq.filter_map to_article 129 133 130 - let get_all_evaluated : t -> evaluated Seq.t = 131 - fun state -> 132 - state.index |> URI.Tbl.to_seq_values |> Seq.filter_map to_evaluated 134 + let get_all_evaluated ~forest = 135 + forest.index |> URI.Tbl.to_seq_values |> Seq.filter_map to_evaluated 133 136 134 137 let get_all_resources : t -> T.content T.resource Seq.t = 135 138 fun state -> state.index |> URI.Tbl.to_seq_values |> Seq.filter_map to_resource
+7 -7
lib/compiler/test/Test_compiler.ml
··· 32 32 let@ path = with_test_forest ~raw_trees ~env ~config in 33 33 Sys.chdir (Eio.Path.native_exn path); 34 34 let forest = State.make ~env ~config ~dev:false () in 35 - Driver.run_with_history Load_all_configured_dirs forest 35 + Driver.run_with_history Load_configured_dirs forest 36 36 in 37 37 Alcotest.(check @@ list action) 38 38 "all actions have run" 39 39 [ 40 - Load_all_configured_dirs; 40 + Load_configured_dirs; 41 41 Parse_all; 42 42 Build_import_graph; 43 43 Expand_all; ··· 48 48 history; 49 49 Alcotest.(check @@ int) 50 50 "no tree is unparsed" 0 51 - (Seq.length (State.get_all_unparsed ~forest)); 51 + (List.length (State.get_all_unparsed ~forest)); 52 52 Alcotest.(check @@ int) 53 53 "no tree is unexpanded" 0 54 54 (Seq.length (State.get_all_unexpanded ~forest)); ··· 57 57 (Seq.length (State.get_all_unevaluated ~forest)); 58 58 Alcotest.(check @@ int) 59 59 "has correct number of articles" 8 60 - (Seq.length (State.get_all_articles forest)) 60 + (Seq.length (State.get_all_articles ~forest)) 61 61 62 62 let test_includes_paths ~env () = 63 63 let config = Config.default () in ··· 65 65 Sys.chdir (Eio.Path.native_exn path); 66 66 let forest, history = 67 67 State.make ~env ~config ~dev:true () 68 - |> Driver.run_with_history Load_all_configured_dirs 68 + |> Driver.run_with_history Load_configured_dirs 69 69 in 70 70 Alcotest.(check int) 71 71 "number of parsed trees" 8 ··· 76 76 Alcotest.(check @@ list action) 77 77 "evaluation succeeded" 78 78 [ 79 - Load_all_configured_dirs; 79 + Load_configured_dirs; 80 80 Parse_all; 81 81 Build_import_graph; 82 82 Expand_all; ··· 105 105 m "In temp dir %s" (Unix.realpath @@ Eio.Path.native_exn tmp_path)); 106 106 let forest = 107 107 State.make ~env ~config ~dev:false () 108 - |> Driver.run_until_done Load_all_configured_dirs 108 + |> Driver.run_until_done Load_configured_dirs 109 109 in 110 110 let reparse_addr = "t8.tree" in 111 111 let reparse_uri = URI.path_to_uri ~base:config.url reparse_addr in
+2 -2
lib/compiler/test/Test_import_graph.ml
··· 64 64 Sys.chdir (Eio.Path.native_exn tmp_dir); 65 65 let forest, history = 66 66 State.make ~env ~config ~dev:false () 67 - |> Driver.run_with_history Load_all_configured_dirs 67 + |> Driver.run_with_history Load_configured_dirs 68 68 in 69 69 Alcotest.(check @@ list action) 70 70 "evaluation succeeded" 71 71 [ 72 - Load_all_configured_dirs; 72 + Load_configured_dirs; 73 73 Parse_all; 74 74 Build_import_graph; 75 75 Expand_all;
+6 -12
lib/frontend/Forester.ml
··· 55 55 let complete ~(forest : State.t) prefix : (string * string) List.t = 56 56 let config = forest.config in 57 57 let@ article = 58 - List.filter_map @~ List.of_seq @@ State.get_all_articles forest 58 + List.filter_map @~ List.of_seq @@ State.get_all_articles ~forest 59 59 in 60 60 let@ uri = Option.bind article.frontmatter.uri in 61 61 let short_uri = URI.display_path_string ~base:config.url uri in ··· 97 97 |> (fun t -> `List t) 98 98 |> Yojson.Safe.to_string 99 99 100 - let outputs_for_article 101 - ~(forest : State.t) 102 - ~emit_legacy_xml 100 + let outputs_for_article ~(forest : State.t) ~emit_legacy_xml 103 101 (article : _ T.article) = 104 102 match article.frontmatter.uri with 105 103 | None -> [] ··· 128 126 let route = asset.uri in 129 127 [(route, asset.content)] 130 128 131 - let outputs_for_json_blob_syndication 132 - ~(forest : State.t) 129 + let outputs_for_json_blob_syndication ~(forest : State.t) 133 130 (syndication : _ T.json_blob_syndication) = 134 131 if URI.host syndication.blob_uri = URI.host forest.config.url then 135 132 let vertices = Forest.run_datalog_query forest.graphs syndication.query in ··· 145 142 [(syndication.blob_uri, json_content)] 146 143 else [] 147 144 148 - let outputs_for_atom_feed_syndication 149 - ~(forest : State.t) 145 + let outputs_for_atom_feed_syndication ~(forest : State.t) 150 146 (syndication : T.atom_feed_syndication) = 151 147 let* atom_nodes = 152 148 Atom_client.render_feed forest ~source_uri:syndication.source_uri ··· 161 157 | T.Atom_feed syndication -> 162 158 outputs_for_atom_feed_syndication ~forest syndication 163 159 164 - let outputs_for_resource 165 - ~(forest : State.t) 166 - ~emit_legacy_xml 160 + let outputs_for_resource ~(forest : State.t) ~emit_legacy_xml 167 161 (evaluated : Tree.evaluated) = 168 162 if not evaluated.route_locally then ok [] 169 163 else ··· 178 172 179 173 let render_forest ~dev ~emit_legacy_xml ~(forest : State.t) : unit = 180 174 let cwd = Eio.Stdenv.cwd forest.env in 181 - let all_resources = forest |> State.get_all_evaluated in 175 + let all_resources = State.get_all_evaluated ~forest in 182 176 Logs.debug (fun m -> m "Rendering %i resources" (Seq.length all_resources)); 183 177 begin 184 178 let json_string = json_manifest ~dev ~forest in
+1 -1
lib/language_server/Completion.ml
··· 280 280 L.CompletionItem.create ~insertText ~label () 281 281 282 282 let addr_completions ~(forest : State.t) : L.CompletionItem.t list = 283 - let articles = List.of_seq @@ State.get_all_articles forest in 283 + let articles = List.of_seq @@ State.get_all_articles ~forest in 284 284 let@ article = List.filter_map @~ articles in 285 285 let frontmatter = article.frontmatter in 286 286 let@ _ = Option.bind frontmatter.title in
+1 -1
lib/search/Search_engine.ml
··· 64 64 in 65 65 let dev = true in 66 66 let forest = Driver.batch_run ~env ~dev ~config ~config_path:"forest.toml" in 67 - let articles = List.of_seq @@ State.get_all_articles forest in 67 + let articles = List.of_seq @@ State.get_all_articles ~forest in 68 68 let index = Index.create articles in 69 69 let size = Obj.reachable_words @@ Obj.repr index in 70 70 Format.printf "index size: %i@." size;
+1 -1
lib/server/Server.ml
··· 106 106 Result.to_option @@ query_parser @@ Uri.pct_decode @@ query) 107 107 in 108 108 let run_query ~forest q = 109 - let result, _ = Driver.update (Query q) forest in 109 + let result = Driver.update (Query q) forest in 110 110 match result with Query_results vertex_set -> Some vertex_set | _ -> None 111 111 in 112 112 match query with