File: api.mld

package info (click to toggle)
ocamlformat 0.27.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,068 kB
  • sloc: ml: 61,288; pascal: 4,739; lisp: 229; sh: 217; makefile: 121
file content (20 lines) | stat: -rw-r--r-- 523 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{0 API}

OCamlformat's library API: {!Ocamlformat}. The entrypoint is the {!Ocamlformat.Translation_unit} module.

A basic usage would be:

{[
let () =
  let conf = Conf.default in
  match
    Translation_unit.parse_and_format Syntax.Use_file conf
      ~output_file:"output.ml" ~input_name:"input.ml"
      ~source:"let x = y"
  with
  | Ok formatted ->
      print_endline formatted
  | Error e ->
      Translation_unit.Error.print Format.err_formatter
        ~debug:conf.opr_opts.debug ~quiet:conf.opr_opts.quiet e
]}