Skip to content

Commit 39c6197

Browse files
author
Guillaume Petiot
authored
Define ocamlformat-lib package (ocaml-ppx#2230)
1 parent 5626844 commit 39c6197

File tree

37 files changed

+112
-63
lines changed

37 files changed

+112
-63
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
- Remove unnecessary parentheses around partially applied infix operators with attributes (#2198, @gpetiot)
4343
- JaneStreet profile: doesn't align infix ops with open paren (#2204, @gpetiot)
4444
- Re-use the type let_binding from the parser instead of value_binding, improve the spacing of let-bindings regarding of having extension or comments (#2219, @gpetiot)
45+
- The `ocamlformat` package now only contains the binary, the library is available through the `ocamlformat-lib` package (#2230, @gpetiot)
4546

4647
### New features
4748

bench/bench.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
open Bechamel
1313
open Toolkit
14-
open Ocamlformat
14+
open Ocamlformat_lib
1515

1616
type range = int * int
1717

bench/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
(executable
1313
(name bench)
14-
(libraries bechamel bechamel-js ocamlformat stdio yojson))
14+
(libraries bechamel bechamel-js ocamlformat-lib stdio yojson))
1515

1616
(rule
1717
(alias runbench)

bin/ocamlformat-rpc/main.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ let info =
7070
as a reply of the same form."
7171
; `P "Unknown commands are ignored." ]
7272
in
73-
Cmd.info "ocamlformat-rpc" ~version:Ocamlformat.Version.current ~doc ~man
73+
Cmd.info "ocamlformat-rpc" ~version:Ocamlformat_lib.Version.current ~doc
74+
~man
7475

7576
let rpc_main_t = Term.(const Ocamlformat_rpc.run $ const ())
7677

bin/ocamlformat/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
(:standard -open Ocamlformat_stdlib))
1919
(instrumentation
2020
(backend bisect_ppx))
21-
(libraries ocamlformat bin_conf))
21+
(libraries ocamlformat-lib bin_conf))
2222

2323
(rule
2424
(with-stdout-to

bin/ocamlformat/main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
(** OCamlFormat *)
1313

14-
open Ocamlformat ;;
14+
open Ocamlformat_lib ;;
1515

1616
Caml.at_exit (Format.pp_print_flush Format.err_formatter) ;;
1717

dune-project

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
(github ocaml-ppx/ocamlformat))
2828

2929
(package
30-
(name ocamlformat)
30+
(name ocamlformat-lib)
3131
(synopsis "Auto-formatter for OCaml code")
3232
(description
3333
"OCamlFormat is a tool to automatically format OCaml code in a uniform style.")
@@ -40,8 +40,6 @@
4040
(>= 1.3.0)))
4141
(base
4242
(>= v0.12.0))
43-
(cmdliner
44-
(>= 1.1.0))
4543
dune
4644
dune-build-info
4745
either
@@ -61,8 +59,6 @@
6159
(= :version)))
6260
(ocp-indent
6361
(>= 1.8.0))
64-
(re
65-
(>= 1.10.3))
6662
stdio
6763
(uuseg
6864
(>= 10.0.0))
@@ -75,6 +71,22 @@
7571
result
7672
camlp-streams))
7773

74+
(package
75+
(name ocamlformat)
76+
(synopsis "Auto-formatter for OCaml code")
77+
(description
78+
"OCamlFormat is a tool to automatically format OCaml code in a uniform style.")
79+
(depends
80+
(ocaml
81+
(>= 4.08))
82+
(cmdliner
83+
(>= 1.1.0))
84+
dune
85+
(ocamlformat-lib
86+
(= :version))
87+
(re
88+
(>= 1.10.3))))
89+
7890
(package
7991
(name ocamlformat-bench)
8092
(synopsis "Auto-formatter for OCaml code")
@@ -91,7 +103,7 @@
91103
(>= 0.2.0))
92104
(bechamel-js
93105
(>= 0.2.0))
94-
(ocamlformat
106+
(ocamlformat-lib
95107
(= :version))
96108
stdio
97109
(yojson

lib-rpc-server/dune

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
(library
22
(name ocamlformat_rpc)
33
(public_name ocamlformat.rpc)
4-
(libraries ocamlformat ocamlformat.bin_conf ocamlformat.rpc_lib_protocol))
4+
(libraries
5+
ocamlformat-lib
6+
ocamlformat.bin_conf
7+
ocamlformat.rpc_lib_protocol))

lib-rpc-server/ocamlformat_rpc.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
(* *)
1010
(**************************************************************************)
1111

12-
open Ocamlformat
12+
open Ocamlformat_lib
1313
open Ocamlformat_stdlib
1414

1515
module IO = struct

lib/bin_conf/Bin_conf.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
(* *)
1010
(**************************************************************************)
1111

12-
open Ocamlformat
12+
open Ocamlformat_lib
1313
open Conf
1414
open Cmdliner
15-
module Decl = Ocamlformat.Conf_decl
15+
module Decl = Conf_decl
1616

1717
type file = Stdin | File of string
1818

lib/bin_conf/Bin_conf.mli

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ val build_config :
1414
-> root:Fpath.t option
1515
-> file:string
1616
-> is_stdin:bool
17-
-> (Ocamlformat.Conf.t, string) Result.t
17+
-> (Ocamlformat_lib.Conf.t, string) Result.t
1818

1919
type file = Stdin | File of string
2020

2121
type input =
22-
{ kind: Ocamlformat.Syntax.t
22+
{ kind: Ocamlformat_lib.Syntax.t
2323
; name: string
2424
; file: file
25-
; conf: Ocamlformat.Conf.t }
25+
; conf: Ocamlformat_lib.Conf.t }
2626

2727
(** Formatting action: input type and source, and output destination. *)
2828
type action =
@@ -32,7 +32,7 @@ type action =
3232
| Inplace of input list (** Format in-place, overwriting input file(s). *)
3333
| Check of input list
3434
(** Check whether the input files already are formatted. *)
35-
| Print_config of Ocamlformat.Conf.t
35+
| Print_config of Ocamlformat_lib.Conf.t
3636
(** Print the configuration and exit. *)
3737
| Numeric of input
3838

lib/bin_conf/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
Ocamlformat_result.Global_scope))
1212
(instrumentation
1313
(backend bisect_ppx))
14-
(libraries ocamlformat re))
14+
(libraries ocamlformat-lib re))

lib/dune

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
(ocamllex Toplevel_lexer)
1515

1616
(library
17-
(name ocamlformat)
18-
(public_name ocamlformat)
17+
(name ocamlformat_lib)
18+
(public_name ocamlformat-lib)
1919
(flags
2020
(:standard
2121
-open

ocamlformat-bench.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ depends: [
1313
"alcotest" {with-test & >= "1.3.0"}
1414
"bechamel" {>= "0.2.0"}
1515
"bechamel-js" {>= "0.2.0"}
16-
"ocamlformat" {= version}
16+
"ocamlformat-lib" {= version}
1717
"stdio"
1818
"yojson" {>= "1.6.0"}
1919
"odoc" {with-doc}

ocamlformat-lib.opam

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This file is generated by dune, edit dune-project instead
2+
opam-version: "2.0"
3+
synopsis: "Auto-formatter for OCaml code"
4+
description:
5+
"OCamlFormat is a tool to automatically format OCaml code in a uniform style."
6+
maintainer: ["OCamlFormat Team <[email protected]>"]
7+
authors: ["Josh Berdine <[email protected]>"]
8+
homepage: "https://github.com/ocaml-ppx/ocamlformat"
9+
bug-reports: "https://github.com/ocaml-ppx/ocamlformat/issues"
10+
depends: [
11+
"ocaml" {>= "4.08"}
12+
"alcotest" {with-test & >= "1.3.0"}
13+
"base" {>= "v0.12.0"}
14+
"dune" {>= "2.8"}
15+
"dune-build-info"
16+
"either"
17+
"fix"
18+
"fpath"
19+
"menhir" {>= "20201216"}
20+
"menhirLib" {>= "20201216"}
21+
"menhirSdk" {>= "20201216"}
22+
"ocaml-version" {>= "3.5.0"}
23+
"ocamlformat-rpc-lib" {with-test & = version}
24+
"ocp-indent" {>= "1.8.0"}
25+
"stdio"
26+
"uuseg" {>= "10.0.0"}
27+
"uutf" {>= "1.0.1"}
28+
"csexp" {>= "1.4.0"}
29+
"astring"
30+
"result"
31+
"camlp-streams"
32+
"odoc" {with-doc}
33+
]
34+
build: [
35+
["dune" "subst"] {dev}
36+
[
37+
"dune"
38+
"build"
39+
"-p"
40+
name
41+
"-j"
42+
jobs
43+
"@install"
44+
"@runtest" {with-test}
45+
"@doc" {with-doc}
46+
]
47+
]
48+
dev-repo: "git+https://github.com/ocaml-ppx/ocamlformat.git"
49+
license: ["MIT" "LGPL-2.1-only WITH OCaml-LGPL-linking-exception"] # OCamlFormat is distributed under the MIT license. Parts of the OCaml library are vendored for OCamlFormat and distributed under their original LGPL 2.1 license

ocamlformat-lib.opam.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
license: ["MIT" "LGPL-2.1-only WITH OCaml-LGPL-linking-exception"] # OCamlFormat is distributed under the MIT license. Parts of the OCaml library are vendored for OCamlFormat and distributed under their original LGPL 2.1 license

ocamlformat.opam

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,10 @@ homepage: "https://github.com/ocaml-ppx/ocamlformat"
99
bug-reports: "https://github.com/ocaml-ppx/ocamlformat/issues"
1010
depends: [
1111
"ocaml" {>= "4.08"}
12-
"alcotest" {with-test & >= "1.3.0"}
13-
"base" {>= "v0.12.0"}
1412
"cmdliner" {>= "1.1.0"}
1513
"dune" {>= "2.8"}
16-
"dune-build-info"
17-
"either"
18-
"fix"
19-
"fpath"
20-
"menhir" {>= "20201216"}
21-
"menhirLib" {>= "20201216"}
22-
"menhirSdk" {>= "20201216"}
23-
"ocaml-version" {>= "3.5.0"}
24-
"ocamlformat-rpc-lib" {with-test & = version}
25-
"ocp-indent" {>= "1.8.0"}
14+
"ocamlformat-lib" {= version}
2615
"re" {>= "1.10.3"}
27-
"stdio"
28-
"uuseg" {>= "10.0.0"}
29-
"uutf" {>= "1.0.1"}
30-
"csexp" {>= "1.4.0"}
31-
"astring"
32-
"result"
33-
"camlp-streams"
3416
"odoc" {with-doc}
3517
]
3618
build: [

test/unit/dune

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
(test
22
(name test_unit)
3-
(package ocamlformat)
4-
(libraries alcotest base ocamlformat))
3+
(package ocamlformat-lib)
4+
(libraries alcotest base ocamlformat-lib))

test/unit/test_ast.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
open! Base
2-
open Ocamlformat
2+
open Ocamlformat_lib
33

44
let test_string_id ~f name ~pass ~fail =
55
let test symbol ~expected =

test/unit/test_conf.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
open Ocamlformat
1+
open Ocamlformat_lib
22

33
let find name =
44
List.find (fun Conf_decl.UI.{names; _} ->

test/unit/test_eol_compat.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
open Ocamlformat
1+
open Ocamlformat_lib
22

33
let normalize_eol_tests =
44
let test name ~exclude_locs input ~lf ~crlf =

test/unit/test_fmt.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
open Base
2-
open Ocamlformat
2+
open Ocamlformat_lib
33

44
let eval_fmt term =
55
let buffer = Buffer.create 0 in

test/unit/test_indent.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
open Ocamlformat
1+
open Ocamlformat_lib
22

33
let read_file f = Stdio.In_channel.with_file f ~f:Stdio.In_channel.input_all
44

test/unit/test_literal_lexer.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
open Base
2-
open Ocamlformat
2+
open Ocamlformat_lib
33

44
let single_quote = '\''
55

test/unit/test_range.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
open Ocamlformat
1+
open Ocamlformat_lib
22

33
let pp =
44
let open Stdlib.Format in

test/unit/test_translation_unit.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
open! Base
2-
open Ocamlformat
2+
open Ocamlformat_lib
33

44
let normalize_eol = Eol_compat.normalize_eol ~line_endings:`Lf
55

test/unit/test_translation_unit.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
val tests : unit Alcotest.test_case list
22

33
val reindent :
4-
source:string -> range:Ocamlformat.Range.t -> int list -> string
4+
source:string -> range:Ocamlformat_lib.Range.t -> int list -> string

test/unit/test_unit.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
open Base
2-
open Ocamlformat
2+
open Ocamlformat_lib
33

44
module Test_location = struct
55
let test_compare_width_decreasing =

vendor/ocaml-common/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(library
22
(name ocaml_common)
3-
(public_name ocamlformat.ocaml_common)
3+
(public_name ocamlformat-lib.ocaml_common)
44
(flags
55
(:standard -w -9 -open Parser_shims))
66
(libraries parser_shims))

vendor/ocamlformat-result/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
(library
22
(name ocamlformat_result)
3-
(public_name ocamlformat.result))
3+
(public_name ocamlformat-lib.result))

vendor/ocamlformat-stdlib/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(library
22
(name ocamlformat_stdlib)
3-
(public_name ocamlformat.ocamlformat_stdlib)
3+
(public_name ocamlformat-lib.ocamlformat_stdlib)
44
(flags
55
(:standard -open Ocaml_common))
66
(libraries base cmdliner ocaml_common fpath stdio))

vendor/ocamlformat_support/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(library
22
(name format_)
3-
(public_name ocamlformat.format_)
3+
(public_name ocamlformat-lib.format_)
44
(flags
55
(:standard -open Parser_shims))
66
(libraries either parser_shims))

vendor/odoc-parser/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
(library
44
(name odoc_parser)
5-
(public_name ocamlformat.odoc_parser)
5+
(public_name ocamlformat-lib.odoc_parser)
66
(instrumentation
77
(backend bisect_ppx))
88
(flags

vendor/parser-extended/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(library
22
(name parser_extended)
3-
(public_name ocamlformat.parser_extended)
3+
(public_name ocamlformat-lib.parser_extended)
44
(flags
55
(:standard -w -9 -open Parser_shims -open Ocaml_common))
66
(libraries compiler-libs.common menhirLib parser_shims ocaml_common))

0 commit comments

Comments
 (0)