ocaml
0
fork

Configure Feed

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

Add Reporter.log, rename plant_raw_forest_from_dirs -> compile

authored by

Kento Okura and committed by
Jon Sterling
07526fdb d1c518c0

+71 -17
+5 -8
bin/forester/main.ml
··· 37 37 let build ~env _ config_filename dev no_theme = 38 38 let config = Config_parser.parse_forest_config_file config_filename in 39 39 Logs.debug (fun m -> m "Parsed config file %s" config_filename); 40 - let forest = Forester.plant_raw_forest_from_dirs ~env ~dev ~config in 40 + let forest = Forester.compile ~env ~dev ~config in 41 41 forest 42 42 |> State.diagnostics 43 43 |> Diagnostic_store.iter (fun _ d -> List.iter Reporter.Tty.display d); ··· 49 49 let export ~env _ config_filename dev = 50 50 let config = Config_parser.parse_forest_config_file config_filename in 51 51 Logs.debug (fun m -> m "Parsed config file %s" config_filename); 52 - let forest = Forester.plant_raw_forest_from_dirs ~env ~dev ~config in 52 + let forest = Forester.compile ~env ~dev ~config in 53 53 forest 54 54 |> State.diagnostics 55 55 |> Diagnostic_store.iter (fun _ d -> List.iter Reporter.Tty.display d); 56 - Forester.render_forest ~dev ~forest; 57 - (* let dirs_to_copy = (if not no_theme then [config.theme] else []) in *) 58 - (* let@ dir_to_copy = List.iter @~ dirs_to_copy in *) 59 56 Forester.export ~forest 60 57 61 58 let new_tree ~env config_filename prefix template random = 62 59 let@ () = Reporter.silence in 63 60 let config = Config_parser.parse_forest_config_file config_filename in 64 - let forest = Forester.plant_raw_forest_from_dirs ~env ~dev: true ~config in 61 + let forest = Forester.compile ~env ~dev: true ~config in 65 62 let mode = if random then `Random else `Sequential in 66 63 let new_tree = Forester.create_tree ~env ~prefix ~template ~mode ~config ~forest in 67 64 Format.printf "%s.tree\n" new_tree ··· 69 66 let complete ~env config_filename title = 70 67 let@ () = Reporter.silence in 71 68 let config = Config_parser.parse_forest_config_file config_filename in 72 - let forest = Forester.plant_raw_forest_from_dirs ~env ~dev: true ~config in 69 + let forest = Forester.compile ~env ~dev: true ~config in 73 70 let@ iri, title = Seq.iter @~ Forester.complete ~forest title in 74 71 Format.printf "%a, %s\n" pp_iri iri title 75 72 76 73 let query_all ~env config_filename = 77 74 let@ () = Reporter.silence in 78 75 let config = Config_parser.parse_forest_config_file config_filename in 79 - let forest = Forester.plant_raw_forest_from_dirs ~env ~config ~dev: true in 76 + let forest = Forester.compile ~env ~config ~dev: true in 80 77 Format.printf "%s" @@ 81 78 Forester.json_manifest ~dev: true ~forest 82 79
+3
lib/core/Reporter.ml
··· 60 60 61 61 type diagnostic = Message.t Asai.Diagnostic.t 62 62 63 + let log pp s = 64 + Logs.app (fun m -> m " ○ %a...@." pp s) 65 + 63 66 let profile msg body = 64 67 let before = Unix.gettimeofday () in 65 68 let result = body () in
+57
lib/core/Reporter.mli
··· 1 + (* 2 + * SPDX-FileCopyrightText: 2024 The Forester Project Contributors 3 + * 4 + * SPDX-License-Identifier: GPL-3.0-or-later 5 + *) 6 + 7 + module Message : 8 + sig 9 + type t = 10 + Tree_not_found of Base.iri 11 + | Duplicate_tree of Base.iri 12 + | Parse_error 13 + | Type_error 14 + | Type_warning 15 + | Resolution_error 16 + | Resolution_warning 17 + | Duplicate_attribute 18 + | Unhandled_case 19 + | Transclusion_loop 20 + | Internal_error 21 + | Configuration_error 22 + | Initialization_warning 23 + | Routing_error 24 + | Profiling 25 + | External_error 26 + | Resource_not_found 27 + | Broken_link 28 + | IO_error 29 + | Log 30 + val pp : 31 + Ppx_deriving_runtime.Format.formatter -> t -> Ppx_deriving_runtime.unit 32 + val show : t -> Ppx_deriving_runtime.string 33 + val default_severity : t -> Asai.Diagnostic.severity 34 + val short_code : t -> string 35 + end 36 + 37 + include module type of Asai.Reporter.Make(Message) 38 + module Tty : module type of Asai.Tty.Make(Message) 39 + 40 + type diagnostic = Message.t Asai.Diagnostic.t 41 + val log : (Format.formatter -> 'a -> unit) -> 'a -> unit 42 + val profile : string -> (unit -> 'a) -> 'a 43 + val easy_run : (unit -> 'a) -> 'a 44 + val silence : (unit -> 'a) -> 'a 45 + val test_run : (unit -> 'a) -> 'a 46 + val lsp_run : 47 + ?init_loc: Asai__.Range.t -> 48 + ?init_backtrace: Asai__.Diagnostic.backtrace -> 49 + ('a -> Message.t Asai__.Diagnostic.t list -> unit) -> 50 + 'a -> 51 + (unit -> unit) -> 52 + unit 53 + val ignore : 54 + ?init_loc: Asai__.Range.t -> 55 + ?init_backtrace: Asai__.Diagnostic.backtrace -> 56 + (unit -> 'a) -> 57 + 'a
+1 -1
lib/core/dune
··· 7 7 (instrumentation (backend bisect_ppx)) 8 8 (preprocess 9 9 (pps ppx_deriving.show ppx_repr)) 10 - (libraries forester.prelude forester.xml_names forester.human_datetime datalog yuujinchou asai ocamlgraph bwd unix iri) 10 + (libraries forester.prelude forester.xml_names forester.human_datetime datalog yuujinchou asai ocamlgraph bwd unix iri logs) 11 11 (public_name forester.core)) 12 12 13 13 (env
+2 -2
lib/frontend/Forester.ml
··· 93 93 let result = State_machine.render_tree ~env ~config ~dev tgt iri in 94 94 Format.printf "%s" result 95 95 96 - let plant_raw_forest_from_dirs ~env ~dev ~(config : Config.t) : State.t = 96 + let compile ~env ~dev ~(config : Config.t) : State.t = 97 97 State_machine.batch_run ~env ~config ~dev 98 98 99 99 let json_manifest ~dev ~(forest : State.t) : string = ··· 150 150 end 151 151 152 152 let export ~(forest : State.t) : unit = 153 - let@ () = Reporter.profile "Export forest" in 153 + Reporter.log Format.pp_print_string "Exporting forest"; 154 154 let local_resources = 155 155 let@ resource = List.filter @~ Forest.get_all_resources forest.resources in 156 156 match resource with
+1 -1
lib/frontend/Forester.mli
··· 12 12 13 13 type target = Target : 'a Render.target -> target 14 14 15 - val plant_raw_forest_from_dirs : 15 + val compile : 16 16 env: env -> 17 17 dev: bool -> 18 18 config: Config.t ->
+2 -5
lib/frontend/State_machine.ml
··· 37 37 | Render_result of 'r 38 38 | Error of 'e 39 39 40 - let log s = 41 - Logs.app (fun m -> m " ○ %s...@." s) 42 - 43 40 let update 44 41 : type a. a action -> state -> (a action * state * (a, _) result) 45 42 = fun msg state -> ··· 71 68 | Load_all -> 72 69 (Parse_all, Phases.load_configured_dirs state, Nothing) 73 70 | Parse_all -> 74 - log "Parse trees"; 71 + Reporter.log Format.pp_print_string "Parse trees"; 75 72 ( 76 73 Build_import_graph, 77 74 Phases.parse ~quit_on_error: false state, ··· 90 87 Nothing 91 88 ) 92 89 | Expand_all -> 93 - log "Expand, evaluate and analyse forest"; 90 + Reporter.log Format.pp_print_string "Expand, evaluate and analyse forest"; 94 91 ( 95 92 Eval_all, 96 93 Phases.expand ~quit_on_error: false state,