Skip to content

Commit 217235c

Browse files
committed
fmt
1 parent 1cf7211 commit 217235c

File tree

12 files changed

+326
-141
lines changed

12 files changed

+326
-141
lines changed

.ocamlformat

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version=0.25.1
2+
assignment-operator=end-line
3+
break-cases=fit
4+
break-fun-decl=wrap
5+
break-fun-sig=wrap
6+
break-infix=wrap
7+
break-infix-before-func=false
8+
break-separators=before
9+
break-sequences=true
10+
cases-exp-indent=2
11+
cases-matching-exp-indent=normal
12+
doc-comments=before
13+
doc-comments-padding=2
14+
doc-comments-tag-only=default
15+
dock-collection-brackets=false
16+
exp-grouping=preserve
17+
field-space=loose
18+
if-then-else=compact
19+
indicate-multiline-delimiters=space
20+
indicate-nested-or-patterns=unsafe-no
21+
infix-precedence=indent
22+
leading-nested-match-parens=false
23+
let-and=sparse
24+
let-binding-spacing=compact
25+
let-module=compact
26+
margin=80
27+
max-indent=2
28+
module-item-spacing=sparse
29+
ocaml-version=4.14.0
30+
ocp-indent-compat=false
31+
parens-ite=false
32+
parens-tuple=always
33+
parse-docstrings=true
34+
sequence-blank-line=preserve-one
35+
sequence-style=terminator
36+
single-case=compact
37+
space-around-arrays=true
38+
space-around-lists=true
39+
space-around-records=true
40+
space-around-variants=true
41+
type-decl=sparse
42+
wrap-comments=false
43+
wrap-fun-args=true

example/print_dir.ml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,40 @@ let () =
2525
(* Printing base dirs *)
2626
Format.printf "* Base dirs:@.";
2727
print_dirs
28-
[ B.home_dir, "home_dir: "
29-
; B.cache_dir, "cache_dir: "
30-
; B.config_dir, "config_dir: "
31-
; B.data_dir, "data_dir: "
32-
; B.data_local_dir, "data_local_dir:"
33-
; B.preference_dir, "preference_dir:"
34-
; B.runtime_dir, "runtime_dir: "
35-
; B.state_dir, "state_dir: "
36-
; B.executable_dir, "executable_dir:"
28+
[ (B.home_dir, "home_dir: ")
29+
; (B.cache_dir, "cache_dir: ")
30+
; (B.config_dir, "config_dir: ")
31+
; (B.data_dir, "data_dir: ")
32+
; (B.data_local_dir, "data_local_dir:")
33+
; (B.preference_dir, "preference_dir:")
34+
; (B.runtime_dir, "runtime_dir: ")
35+
; (B.state_dir, "state_dir: ")
36+
; (B.executable_dir, "executable_dir:")
3737
];
3838

3939
(* Printing user dirs *)
4040
Format.printf "* User dirs:@.";
4141
print_dirs
42-
[ U.home_dir, "home_dir: "
43-
; U.audio_dir, "audio_dir: "
44-
; U.desktop_dir, "desktop_dir: "
45-
; U.document_dir, "document_dir: "
46-
; U.download_dir, "download_dir: "
47-
; U.font_dir, "font_dir: "
48-
; U.picture_dir, "picture_dir: "
49-
; U.public_dir, "public_dir: "
50-
; U.template_dir, "template_dir: "
51-
; U.video_dir, "video_dir: "
42+
[ (U.home_dir, "home_dir: ")
43+
; (U.audio_dir, "audio_dir: ")
44+
; (U.desktop_dir, "desktop_dir: ")
45+
; (U.document_dir, "document_dir: ")
46+
; (U.download_dir, "download_dir: ")
47+
; (U.font_dir, "font_dir: ")
48+
; (U.picture_dir, "picture_dir: ")
49+
; (U.public_dir, "public_dir: ")
50+
; (U.template_dir, "template_dir: ")
51+
; (U.video_dir, "video_dir: ")
5252
];
5353

5454
(* Printing project dirs*)
5555
Format.printf "* Project dirs:@.";
5656
print_dirs
57-
[ P.cache_dir, "cache_dir: "
58-
; P.config_dir, "config_dir: "
59-
; P.data_dir, "data_dir: "
60-
; P.data_local_dir, "data_local_dir:"
61-
; P.preference_dir, "preference_dir:"
62-
; P.state_dir, "state_dir: "
63-
; P.runtime_dir, "runtime_dir: "
57+
[ (P.cache_dir, "cache_dir: ")
58+
; (P.config_dir, "config_dir: ")
59+
; (P.data_dir, "data_dir: ")
60+
; (P.data_local_dir, "data_local_dir:")
61+
; (P.preference_dir, "preference_dir:")
62+
; (P.state_dir, "state_dir: ")
63+
; (P.runtime_dir, "runtime_dir: ")
6464
]

example/quick_start.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
let () =
22
let module App_id = struct
33
let qualifier = "com"
4+
45
let organization = "YourCompany"
6+
57
let application = "yourapp"
68
end in
79
let module M = Directories.Project_dirs (App_id) in

src/directories.mli

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,63 @@
11
module Base_dirs () : sig
22
val home_dir : string option
3+
34
val cache_dir : string option
5+
46
val config_dir : string option
7+
58
val data_dir : string option
9+
610
val data_local_dir : string option
11+
712
val preference_dir : string option
13+
814
val runtime_dir : string option
15+
916
val state_dir : string option
17+
1018
val executable_dir : string option
1119
end
1220

1321
module User_dirs () : sig
1422
val home_dir : string option
23+
1524
val audio_dir : string option
25+
1626
val desktop_dir : string option
27+
1728
val document_dir : string option
29+
1830
val download_dir : string option
31+
1932
val font_dir : string option
33+
2034
val picture_dir : string option
35+
2136
val public_dir : string option
37+
2238
val template_dir : string option
39+
2340
val video_dir : string option
2441
end
2542

2643
module Project_dirs (App_id : sig
2744
val qualifier : string
45+
2846
val organization : string
47+
2948
val application : string
3049
end) : sig
3150
val cache_dir : string option
51+
3252
val config_dir : string option
53+
3354
val data_dir : string option
55+
3456
val data_local_dir : string option
57+
3558
val preference_dir : string option
59+
3660
val runtime_dir : string option
61+
3762
val state_dir : string option
3863
end

src/directories_common.ml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,12 @@ module type App_id = sig
99
end
1010

1111
(* TODO: remove once we drop 4.07 *)
12-
let option_map f = function
13-
| None -> None
14-
| Some v -> Some (f v)
12+
let option_map f = function None -> None | Some v -> Some (f v)
1513

1614
(* TODO: remove once we drop 4.07 *)
17-
let option_bind o f =
18-
match o with
19-
| None -> None
20-
| Some v -> f v
15+
let option_bind o f = match o with None -> None | Some v -> f v
2116

22-
let relative_opt dir =
23-
if Filename.is_relative dir then
24-
None
25-
else
26-
Some dir
17+
let relative_opt dir = if Filename.is_relative dir then None else Some dir
2718

2819
let getenv env =
2920
match Sys.getenv env with
@@ -39,15 +30,10 @@ let lower_and_replace_ws s replace =
3930
let should_replace = ref false in
4031
for i = 0 to String.length s - 1 do
4132
match s.[i] with
42-
| ' '
43-
| '\012'
44-
| '\n'
45-
| '\r'
46-
| '\t' ->
33+
| ' ' | '\012' | '\n' | '\r' | '\t' ->
4734
if !should_replace then (
4835
Buffer.add_string buff replace;
49-
should_replace := false
50-
)
36+
should_replace := false )
5137
| c ->
5238
Buffer.add_char buff c;
5339
should_replace := true

src/linux/directories.ml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,11 @@ module User_dirs () = struct
6666
option_map (fun dir -> dir / "user-dirs.dirs") Base_dirs.config_dir
6767

6868
let user_dirs =
69-
option_bind user_dirs (fun f ->
70-
if Sys.file_exists f then
71-
Some f
72-
else
73-
None)
69+
option_bind user_dirs (fun f -> if Sys.file_exists f then Some f else None)
7470

7571
let user_dirs =
7672
option_bind user_dirs (fun f ->
77-
if Sys.is_directory f then
78-
None
79-
else
80-
Some f)
73+
if Sys.is_directory f then None else Some f )
8174

8275
let user_shell = getenv "SHELL"
8376

@@ -91,9 +84,7 @@ module User_dirs () = struct
9184
in
9285
let xdg = input_line chan in
9386
let result = Unix.close_process_in chan in
94-
match result with
95-
| WEXITED 0 -> Some xdg
96-
| _ -> None
87+
match result with WEXITED 0 -> Some xdg | _ -> None
9788
with _ -> None )
9889
| _ -> None
9990

@@ -140,7 +131,8 @@ end
140131
module Project_dirs (App_id : App_id) = struct
141132
module Base_dirs = Base_dirs ()
142133

143-
let project_path = Directories_common.lower_and_replace_ws App_id.application ""
134+
let project_path =
135+
Directories_common.lower_and_replace_ws App_id.application ""
144136

145137
let concat_project_path = option_map (fun dir -> dir / project_path)
146138

src/macos/directories.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ module Project_dirs (App_id : App_id) = struct
8181

8282
let qualifier = Directories_common.lower_and_replace_ws App_id.qualifier "-"
8383

84-
let organization = Directories_common.lower_and_replace_ws App_id.organization "-"
84+
let organization =
85+
Directories_common.lower_and_replace_ws App_id.organization "-"
8586

86-
let application = Directories_common.lower_and_replace_ws App_id.application "-"
87+
let application =
88+
Directories_common.lower_and_replace_ws App_id.application "-"
8789

8890
let project_path =
8991
Format.sprintf "%s.%s.%s" qualifier organization application

src/windows/bindings/gen_functions.ml

100755100644
Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
21
let print_defines fmt =
32
List.iter (fun (d, v) -> Format.fprintf fmt "#define %s (%s)@\n" d v)
43

5-
let print_headers fmt =
6-
List.iter (Format.fprintf fmt "#include <%s>@\n")
4+
let print_headers fmt = List.iter (Format.fprintf fmt "#include <%s>@\n")
75

8-
let make_functions_stubs
9-
(c_defines : (string * string) list)
10-
(c_headers : string list)
11-
(functions_functor : (module Cstubs.BINDINGS)) =
6+
let make_functions_stubs (c_defines : (string * string) list)
7+
(c_headers : string list) (functions_functor : (module Cstubs.BINDINGS)) =
128
let fmt = Format.std_formatter in
139
begin
1410
match Sys.argv.(1) with
1511
| "c" ->
16-
print_defines fmt c_defines;
17-
print_headers fmt c_headers;
18-
Cstubs.write_c ~prefix:"win_stub" fmt functions_functor
19-
| "ml" ->
20-
Cstubs.write_ml ~prefix:"win_stub" fmt functions_functor
12+
print_defines fmt c_defines;
13+
print_headers fmt c_headers;
14+
Cstubs.write_c ~prefix:"win_stub" fmt functions_functor
15+
| "ml" -> Cstubs.write_ml ~prefix:"win_stub" fmt functions_functor
2116
| s -> failwith ("unknown functions " ^ s)
2217
end;
2318
Format.pp_print_flush fmt ()
2419

2520
let () =
2621
make_functions_stubs
27-
[ "NTDDI_VERSION", "NTDDI_VISTA" ]
22+
[ ("NTDDI_VERSION", "NTDDI_VISTA") ]
2823
[ "windows.h"; "shlobj.h" ]
2924
(module Win_functions_functor.Apply)

src/windows/bindings/win_functions.ml

100755100644
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
2-
include Win_functions_functor.Apply(Win_functions_stubs)
1+
include Win_functions_functor.Apply (Win_functions_stubs)

0 commit comments

Comments
 (0)