Skip to content

Commit a551ba3

Browse files
panglesdjonludlam
authored andcommitted
Driver: added named arguments for readability
Signed-off-by: Paul-Elliot <[email protected]>
1 parent 365aa80 commit a551ba3

File tree

6 files changed

+32
-28
lines changed

6 files changed

+32
-28
lines changed

src/driver/dune_style.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ let of_dune_build dir =
3636
in
3737
let pkg_dir = Fpath.rem_prefix dir path |> Option.get in
3838
( pkg_dir,
39-
Packages.Lib.v pkg_dir
40-
(Util.StringMap.singleton libname libname)
41-
libname path (Some cmtidir) ))
39+
Packages.Lib.v ~pkg_dir
40+
~libname_of_archive:(Util.StringMap.singleton libname libname)
41+
~pkg_name:libname ~dir:path ~cmtidir:(Some cmtidir) ))
4242
libs
4343
in
4444
let packages =

src/driver/odoc_driver.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,15 +509,15 @@ let run libs verbose packages_dir odoc_dir odocl_dir html_dir stats nb_workers
509509

510510
let all =
511511
match (voodoo, package_name, dune_style, packages_dir) with
512-
| true, Some p, None, None -> Voodoo.of_voodoo p blessed
512+
| true, Some p, None, None -> Voodoo.of_voodoo p ~blessed
513513
| false, None, Some dir, None -> Dune_style.of_dune_build dir
514514
| false, None, None, packages_dir ->
515515
let libs = if libs = [] then Ocamlfind.all () else libs in
516516
let libs =
517517
List.map Ocamlfind.sub_libraries libs
518518
|> List.fold_left Util.StringSet.union Util.StringSet.empty
519519
in
520-
Packages.of_libs packages_dir libs
520+
Packages.of_libs ~packages_dir libs
521521
| true, None, _, _ -> failwith "--voodoo requires --package-name"
522522
| false, Some _, _, _ -> failwith "--package-name requires --voodoo"
523523
| true, _, _, Some _ | false, _, Some _, Some _ ->

src/driver/packages.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ module Module = struct
184184
end
185185

186186
module Lib = struct
187-
let v pkg_dir libname_of_archive pkg_name dir cmtidir =
187+
let v ~pkg_dir ~libname_of_archive ~pkg_name ~dir ~cmtidir =
188188
Logs.debug (fun m ->
189189
m "Classifying dir %a for package %s" Fpath.pp dir pkg_name);
190190
let dirs =
@@ -233,7 +233,7 @@ let pp ppf t =
233233
Fmt.(list ~sep:sp Lib.pp)
234234
t.libraries
235235

236-
let of_libs packages_dir libs =
236+
let of_libs ~packages_dir libs =
237237
let libs = Util.StringSet.to_seq libs |> List.of_seq in
238238
let results = List.map (fun x -> (x, Ocamlfind.deps [ x ])) libs in
239239
let all_libs_set =
@@ -371,7 +371,10 @@ let of_libs packages_dir libs =
371371
| Some pkg ->
372372
let pkg_dir = pkg_dir packages_dir pkg.name in
373373

374-
let libraries = Lib.v pkg_dir libname_of_archive pkg.name dir None in
374+
let libraries =
375+
Lib.v ~pkg_dir ~libname_of_archive ~pkg_name:pkg.name ~dir
376+
~cmtidir:None
377+
in
375378
let libraries =
376379
List.filter
377380
(fun l -> Util.StringSet.mem l.archive_name archives)

src/driver/packages.mli

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ type libty = {
6767
modules : modulety list;
6868
}
6969

70+
val parent_of_pkg : Fpath.t -> Fpath.t
71+
72+
module Lib : sig
73+
val v :
74+
pkg_dir:Fpath.t ->
75+
libname_of_archive:string Util.StringMap.t ->
76+
pkg_name:string ->
77+
dir:Fpath.t ->
78+
cmtidir:Fpath.t option ->
79+
libty list
80+
end
81+
7082
type t = {
7183
name : string;
7284
version : string;
@@ -82,17 +94,5 @@ val pp : Format.formatter -> t -> unit
8294

8395
type set = t Util.StringMap.t
8496

85-
val of_libs : Fpath.t option -> Util.StringSet.t -> set
8697
(** Turns a set of libraries into a map from library name to package *)
87-
88-
val parent_of_pkg : Fpath.t -> Fpath.t
89-
90-
module Lib : sig
91-
val v :
92-
Fpath.t ->
93-
string Util.StringMap.t ->
94-
string ->
95-
Fpath.t ->
96-
Fpath.t option ->
97-
libty list
98-
end
98+
val of_libs : packages_dir:Fpath.t option -> Util.StringSet.t -> set

src/driver/voodoo.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ let process_package pkg =
137137
(List.concat_map
138138
(fun directory ->
139139
Format.eprintf "Processing directory: %a\n%!" Fpath.pp directory;
140-
Packages.Lib.v (top_dir pkg) libname_of_archive pkg.name
141-
directory None)
140+
Packages.Lib.v ~pkg_dir:(top_dir pkg) ~libname_of_archive
141+
~pkg_name:pkg.name ~dir:directory ~cmtidir:None)
142142
Fpath.(Set.to_list directories)))
143143
metas
144144
in
@@ -161,9 +161,10 @@ let process_package pkg =
161161
(fun libdir ->
162162
Logs.debug (fun m ->
163163
m "Processing directory without META: %a" Fpath.pp libdir);
164-
Packages.Lib.v (top_dir pkg) Util.StringMap.empty pkg.name
165-
Fpath.(pkg_path // libdir)
166-
None)
164+
Packages.Lib.v ~pkg_dir:(top_dir pkg)
165+
~libname_of_archive:Util.StringMap.empty ~pkg_name:pkg.name
166+
~dir:Fpath.(pkg_path // libdir)
167+
~cmtidir:None)
167168
libdirs_without_meta
168169
in
169170
Printf.eprintf "Found %d metas" (List.length metas);
@@ -187,7 +188,7 @@ let pp ppf v =
187188

188189
let () = ignore pp
189190

190-
let of_voodoo pkg_name blessed =
191+
let of_voodoo pkg_name ~blessed =
191192
let contents =
192193
Bos.OS.Dir.fold_contents ~dotfiles:true
193194
(fun p acc -> p :: acc)

src/driver/voodoo.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
val find_universe_and_version :
22
string -> (string * string, [> `Msg of string ]) result
33

4-
val of_voodoo : string -> bool -> Packages.set
4+
val of_voodoo : string -> blessed:bool -> Packages.set

0 commit comments

Comments
 (0)