ocaml
0
fork

Configure Feed

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

State: remember config path

+43 -23
+13 -13
bin/forester/main.ml
··· 40 40 in 41 41 Format.asprintf "%s" major 42 42 43 - let build ~env _ config_filename dev no_theme emit_legacy_xml = 44 - match Config_parser.parse_forest_config_file config_filename with 43 + let build ~env _ config_path dev no_theme emit_legacy_xml = 44 + match Config_parser.parse_forest_config_file config_path with 45 45 | Error exn -> 46 46 Format.printf "%a@." 47 47 Grace_ansi_renderer.(pp_diagnostic ?config:None ?code_to_string:None) ··· 64 64 } 65 65 else config 66 66 in 67 - Logs.debug (fun m -> m "Parsed config file %s" config_filename); 68 - let forest = Driver.batch_run ~env ~dev ~config in 67 + Logs.debug (fun m -> m "Parsed config file %s" config_path); 68 + let forest = Driver.batch_run ~env ~dev ~config ~config_path in 69 69 forest.diagnostics 70 70 |> URI.Tbl.iter (fun _ d -> 71 71 List.iter ··· 89 89 Forester.render_forest ~dev ~forest ~emit_legacy_xml; 90 90 Logs.app (fun m -> m "Success!") 91 91 92 - let new_tree ~env config_filename dest_dir prefix template random = 93 - match Config_parser.parse_forest_config_file config_filename with 92 + let new_tree ~env config_path dest_dir prefix template random = 93 + match Config_parser.parse_forest_config_file config_path with 94 94 | Error exn -> 95 95 Format.printf "%a@." 96 96 Grace_ansi_renderer.(pp_diagnostic ?config:None ?code_to_string:None) 97 97 exn 98 98 | Ok config -> begin 99 - let forest = Driver.batch_run ~env ~dev:true ~config in 99 + let forest = Driver.batch_run ~env ~dev:true ~config ~config_path in 100 100 let mode = if random then `Random else `Sequential in 101 101 match 102 102 Forester.create_tree ~env ~dest_dir ~prefix ~template ~mode ~forest ··· 108 108 exn 109 109 end 110 110 111 - let complete ~env config_filename title = 112 - match Config_parser.parse_forest_config_file config_filename with 111 + let complete ~env config_path title = 112 + match Config_parser.parse_forest_config_file config_path with 113 113 | Error exn -> 114 114 Format.printf "%a@." 115 115 Grace_ansi_renderer.(pp_diagnostic ?config:None ?code_to_string:None) 116 116 exn 117 117 | Ok config -> 118 - let forest = Driver.batch_run ~env ~dev:true ~config in 118 + let forest = Driver.batch_run ~env ~dev:true ~config ~config_path in 119 119 let@ uri, title = List.iter @~ Forester.complete ~forest title in 120 120 Format.printf "%s, %s\n" uri title 121 121 122 - let query_all ~env config_filename = 123 - match Config_parser.parse_forest_config_file config_filename with 122 + let query_all ~env config_path = 123 + match Config_parser.parse_forest_config_file config_path with 124 124 | Error exn -> 125 125 Format.printf "%a@." 126 126 Grace_ansi_renderer.(pp_diagnostic ?config:None ?code_to_string:None) 127 127 exn 128 128 | Ok config -> 129 - let forest = Driver.batch_run ~env ~config ~dev:true in 129 + let forest = Driver.batch_run ~env ~config ~dev:true ~config_path in 130 130 Format.printf "%s" (Forester.json_manifest ~dev:true ~forest) 131 131 132 132 let default_config_str =
+20 -2
lib/compiler/Driver.ml
··· 26 26 | Report_errors (_, next_action) -> (next_action, forest) 27 27 | Load_all_configured_dirs -> 28 28 let errors, paths = Eio_util.paths_of_dirs ~env forest.config.trees in 29 + let errors = 30 + List.map 31 + (fun d -> 32 + Diagnostic. 33 + { 34 + d with 35 + code = Some Configuration_error; 36 + labels = 37 + Label.createf 38 + ~range: 39 + (* NOTE: When we switch to a better toml parsing library, we can actually report the location*) 40 + Range.(initial (`File (Option.get @@ forest.config_path))) 41 + ~priority:Primary "" 42 + :: d.labels; 43 + }) 44 + errors 45 + in 29 46 let () = 30 47 let@ tree_dir = List.iter @~ paths in 31 48 assert (Eio.Path.is_directory tree_dir); ··· 176 193 fun acc x -> acc || x.severity = Error || x.severity = Bug) 177 194 false 178 195 179 - let batch_run ~env ~(config : Config.t) ~dev = 196 + let batch_run ~env ~(config : Config.t) ~config_path ~dev = 180 197 let init = 181 - State.make ~env ~config ~dev () |> plant_assets |> implant_foreign 198 + State.make ~env ~config ~dev ~config_path () 199 + |> plant_assets |> implant_foreign 182 200 in 183 201 let rec go action state = 184 202 let new_action, new_state = update action state in
+3 -1
lib/compiler/State.ml
··· 20 20 env: Eio_unix.Stdenv.base; 21 21 dev: bool; 22 22 config: Config.t; 23 + config_path: string option; 23 24 index: Tree.t URI.Tbl.t; 24 25 diagnostics: Message.t Grace.Diagnostic.t list URI.Tbl.t; 25 26 graphs: (module Forest_graphs.S); ··· 34 35 } 35 36 36 37 let make ~(env : Eio_unix.Stdenv.base) ~(config : Config.t) ~(dev : bool) 37 - ?(graphs = (module Forest_graphs.Make () : Forest_graphs.S)) 38 + ?config_path ?(graphs = (module Forest_graphs.Make () : Forest_graphs.S)) 38 39 ?(import_graph = Forest_graph.create ~size:1000 ()) 39 40 ?(resolver = URI.Tbl.create 1000) ?(index = URI.Tbl.create 1000) 40 41 ?(diagnostics = URI.Tbl.create 1000) ?(usages = Hashtbl.create 1000) ··· 45 46 env; 46 47 dev; 47 48 config; 49 + config_path; 48 50 index; 49 51 diagnostics; 50 52 resolver;
+1 -1
lib/compiler/test/Test_compiler.ml
··· 134 134 (Forest_graph.in_degree reparsed.import_graph vtx > 0) 135 135 136 136 let test_omits_paths ~env () = 137 - let forest = Driver.batch_run ~env ~config ~dev:false in 137 + let forest = Driver.batch_run ~env ~config ~dev:false ~config_path:"" in 138 138 let path = 139 139 match forest.@{URI.of_string_exn "http://forest.local/t8/"} with 140 140 | Some (Article {frontmatter = {source_path; _}; _}) -> source_path
+1 -1
lib/compiler/test/Test_errors.ml
··· 33 33 let test () = 34 34 let@ tmp_dir = with_test_forest ~env ~raw_trees ~config in 35 35 Sys.chdir (Eio.Path.native_exn tmp_dir); 36 - let forest = Driver.batch_run ~env ~config ~dev:false in 36 + let forest = Driver.batch_run ~env ~config ~dev:false ~config_path:"" in 37 37 Alcotest.(check @@ list action) 38 38 "" 39 39 [
+1 -1
lib/search/Search_engine.ml
··· 56 56 Result.get_ok @@ Config_parser.parse_forest_config_file "forest.toml" 57 57 in 58 58 let dev = true in 59 - let forest = Driver.batch_run ~env ~dev ~config in 59 + let forest = Driver.batch_run ~env ~dev ~config ~config_path:"forest.toml" in 60 60 let articles = List.of_seq @@ State.get_all_articles forest in 61 61 let index = Index.create articles in 62 62 let size = Obj.reachable_words @@ Obj.repr index in
+4 -4
lib/server/Server.ml
··· 200 200 in 201 201 (H.div [] [P.txt "%s" error], `OK) 202 202 | Ok config -> 203 - let f = Driver.batch_run ~env ~config ~dev:true in 203 + let f = Driver.batch_run ~env ~config ~dev:true ~config_path:filename in 204 204 forest := Some f; 205 205 let home = 206 206 match f.@{Config.home_uri config} with ··· 283 283 let forest = 284 284 match config with 285 285 | None -> ref None 286 - | Some config -> ( 287 - match Config_parser.parse_forest_config_file config with 286 + | Some config_path -> ( 287 + match Config_parser.parse_forest_config_file config_path with 288 288 | Error _ -> ref None 289 289 | Ok config -> 290 - let forest = Driver.batch_run ~env ~dev ~config in 290 + let forest = Driver.batch_run ~env ~dev ~config ~config_path in 291 291 ref (Some forest)) 292 292 in 293 293 let socket =