@@ -85,7 +85,7 @@ let find_partials odoc_dir : Odoc_unit.intf Odoc_unit.unit Util.StringMap.t * _
85
85
| Ok h -> (h, tbl)
86
86
| Error _ -> (* odoc_dir doesn't exist...? *) (Util.StringMap. empty, tbl)
87
87
88
- let compile ?partial ~output_dir ?linked_dir :_ (all : Odoc_unit.t list) =
88
+ let compile ?partial ~partial_dir ?linked_dir :_ (all : Odoc_unit.t list) =
89
89
(* let linked_dir = Option.value linked_dir ~default:output_dir in *)
90
90
let intf_units, impl_units, mld_units =
91
91
List. fold_left
@@ -102,7 +102,7 @@ let compile ?partial ~output_dir ?linked_dir:_ (all : Odoc_unit.t list) =
102
102
let hashes = mk_byhash intf_units in
103
103
let other_hashes, tbl =
104
104
match partial with
105
- | Some _ -> find_partials output_dir
105
+ | Some _ -> find_partials partial_dir
106
106
| None -> (Util.StringMap. empty, Hashtbl. create 10 )
107
107
in
108
108
let all_hashes =
@@ -127,29 +127,6 @@ let compile ?partial ~output_dir ?linked_dir:_ (all : Odoc_unit.t list) =
127
127
None )
128
128
deps
129
129
in
130
-
131
- (* let includes = Fpath.Set.add output_dir includes in ?????????? *)
132
-
133
- (* TOOOODOOOOO *)
134
- (* let impl = *)
135
- (* match modty.m_impl with *)
136
- (* | Some impl -> ( *)
137
- (* match impl.mip_src_info with *)
138
- (* | Some si -> *)
139
- (* let odoc_file = Fpath.(output_dir // impl.mip_odoc_file) in *)
140
- (* let odocl_file = Fpath.(linked_dir // impl.mip_odocl_file) in *)
141
- (* Odoc.compile_impl ~output_dir ~input_file:impl.mip_path *)
142
- (* ~includes ~parent_id:impl.mip_parent_id ~source_id:si.src_id; *)
143
- (* Atomic.incr Stats.stats.compiled_impls; *)
144
- (* Some *)
145
- (* { *)
146
- (* impl_odoc = odoc_file; *)
147
- (* impl_odocl = odocl_file; *)
148
- (* src = si.src_path; *)
149
- (* } *)
150
- (* | None -> None) *)
151
- (* | None -> None *)
152
- (* in *)
153
130
let includes = Fpath.Set. of_list unit .include_dirs in
154
131
Odoc. compile ~output_dir: unit .output_dir ~input_file: unit .input_file
155
132
~includes ~parent_id: unit .parent_id;
@@ -229,61 +206,52 @@ let link : compiled list -> _ =
229
206
in
230
207
Fiber.List. map link compiled
231
208
232
- (* let index_one ~odocl_dir pkg_name pkg = *)
233
- (* let dir = pkg.Packages.pkg_dir in *)
234
- (* let output_file = Fpath.(odocl_dir // dir / Odoc.index_filename) in *)
235
- (* let libs = *)
236
- (* List.map *)
237
- (* (fun lib -> (lib.Packages.lib_name, Fpath.(odocl_dir // lib.odoc_dir))) *)
238
- (* pkg.Packages.libraries *)
239
- (* in *)
240
- (* Odoc.compile_index ~json:false ~output_file ~libs *)
241
- (* ~docs:[ (pkg_name, Fpath.(odocl_dir // pkg.mld_odoc_dir)) ] *)
242
- (* () *)
243
-
244
- (* let index ~odocl_dir pkgs = Util.StringMap.iter (index_one ~odocl_dir) pkgs *)
245
-
246
- (* let sherlodoc_index_one ~html_dir ~odocl_dir _ pkg_content = *)
247
- (* let inputs = *)
248
- (* [ Fpath.(odocl_dir // pkg_content.Packages.pkg_dir / Odoc.index_filename) ] *)
249
- (* in *)
250
- (* let dst = Fpath.(html_dir // Sherlodoc.db_js_file pkg_content.pkg_dir) in *)
251
- (* let dst_dir, _ = Fpath.split_base dst in *)
252
- (* Util.mkdir_p dst_dir; *)
253
- (* Sherlodoc.index ~format:`js ~inputs ~dst () *)
254
-
255
- (* let sherlodoc ~html_dir ~odocl_dir pkgs = *)
256
- (* ignore @@ Bos.OS.Dir.create html_dir; *)
257
- (* Sherlodoc.js Fpath.(html_dir // Sherlodoc.js_file); *)
258
- (* Util.StringMap.iter (sherlodoc_index_one ~html_dir ~odocl_dir) pkgs; *)
259
- (* let format = `marshal in *)
260
- (* let dst = Fpath.(html_dir // Sherlodoc.db_marshal_file) in *)
261
- (* let dst_dir, _ = Fpath.split_base dst in *)
262
- (* Util.mkdir_p dst_dir; *)
263
- (* let inputs = *)
264
- (* pkgs |> Util.StringMap.bindings *)
265
- (* |> List.map (fun (_pkgname, pkg) -> *)
266
- (* Fpath.(odocl_dir // pkg.Packages.pkg_dir / Odoc.index_filename)) *)
267
- (* in *)
268
- (* Sherlodoc.index ~format ~inputs ~dst () *)
209
+ let sherlodoc_index_one ~output_dir (index : Odoc_unit.index ) =
210
+ let inputs = [ index.output_file ] in
211
+ let rel_path = Fpath. (index.search_dir / " sherlodoc_db.js" ) in
212
+ let dst = Fpath. (output_dir // rel_path) in
213
+ let dst_dir, _ = Fpath. split_base dst in
214
+ Util. mkdir_p dst_dir;
215
+ Sherlodoc. index ~format: `js ~inputs ~dst () ;
216
+ rel_path
269
217
270
- let html_generate output_dir (* ~odocl_dir *) linked =
218
+ let html_generate output_dir linked =
219
+ let tbl = Hashtbl. create 10 in
220
+ Sherlodoc. js Fpath. (output_dir // Sherlodoc. js_file);
221
+ let compile_index : Odoc_unit.index -> _ =
222
+ fun index ->
223
+ let compile_index_one
224
+ ({ pkg_args = { pages; libs } ; output_file; json; search_dir = _ } as
225
+ index :
226
+ Odoc_unit. index ) =
227
+ let () = Odoc. compile_index ~json ~output_file ~libs ~docs: pages () in
228
+ sherlodoc_index_one ~output_dir index
229
+ in
230
+ match Hashtbl. find_opt tbl index.output_file with
231
+ | None ->
232
+ let p, r = Promise. create () in
233
+ Hashtbl. add tbl index.output_file p;
234
+ let rel_path = compile_index_one index in
235
+ Atomic. incr Stats. stats.generated_indexes;
236
+ Promise. resolve r rel_path;
237
+ rel_path
238
+ | Some p -> Promise. await p
239
+ in
271
240
let html_generate : linked -> unit =
272
241
fun l ->
242
+ let output_dir = Fpath. to_string output_dir in
243
+ let input_file = l.odocl_file in
273
244
match l.kind with
274
245
| `Intf { hidden = true ; _ } -> ()
275
246
| `Impl { src_path; _ } ->
276
- Odoc. html_generate ~search_uris: [] ?index:None
277
- ~output_dir: (Fpath. to_string output_dir)
278
- ~input_file: l.odocl_file ~source: src_path () ;
247
+ Odoc. html_generate ~search_uris: [] ~output_dir ~input_file
248
+ ~source: src_path () ;
279
249
Atomic. incr Stats. stats.generated_units
280
250
| _ ->
281
- (* let pkg_dir = l. in *)
282
- (* let search_uris = [ Sherlodoc.db_js_file pkg_dir; Sherlodoc.js_file ] in *)
283
- (* let index = Some Fpath.(odocl_dir // pkg_dir / Odoc.index_filename) in *)
284
- Odoc. html_generate ~search_uris: [] ?index:None
285
- ~output_dir: (Fpath. to_string output_dir)
286
- ~input_file: l.odocl_file ?source:None (* l.src *) () ;
251
+ let db_path = compile_index l.index in
252
+ let search_uris = [ db_path; Sherlodoc. js_file ] in
253
+ let index = l.index.output_file in
254
+ Odoc. html_generate ~search_uris ~index ~output_dir ~input_file () ;
287
255
Atomic. incr Stats. stats.generated_units
288
256
in
289
257
Fiber.List. iter html_generate linked
0 commit comments