package ocamlformat

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Configuration options

type fmt_opts = {
  1. assignment_operator : [ `Begin_line | `End_line ];
  2. break_before_in : [ `Fit_or_vertical | `Auto ];
  3. break_cases : [ `Fit | `Nested | `Toplevel | `Fit_or_vertical | `All ];
  4. break_collection_expressions : [ `Wrap | `Fit_or_vertical ];
  5. break_infix : [ `Wrap | `Fit_or_vertical ];
  6. break_infix_before_func : Ocamlformat_stdlib.bool;
  7. break_fun_decl : [ `Wrap | `Fit_or_vertical | `Smart ];
  8. break_fun_sig : [ `Wrap | `Fit_or_vertical | `Smart ];
  9. break_separators : [ `Before | `After ];
  10. break_sequences : Ocamlformat_stdlib.bool;
  11. break_string_literals : [ `Auto | `Never ];
    (*

    How to potentially break string literals into new lines.

    *)
  12. break_struct : Ocamlformat_stdlib.bool;
  13. cases_exp_indent : Ocamlformat_stdlib.int;
  14. cases_matching_exp_indent : [ `Normal | `Compact ];
  15. disambiguate_non_breaking_match : Ocamlformat_stdlib.bool;
  16. doc_comments : [ `Before | `Before_except_val | `After_when_possible ];
  17. doc_comments_padding : Ocamlformat_stdlib.int;
  18. doc_comments_tag_only : [ `Fit | `Default ];
  19. dock_collection_brackets : Ocamlformat_stdlib.bool;
  20. exp_grouping : [ `Parens | `Preserve ];
  21. extension_indent : Ocamlformat_stdlib.int;
  22. field_space : [ `Tight | `Loose | `Tight_decl ];
  23. function_indent : Ocamlformat_stdlib.int;
  24. function_indent_nested : [ `Always | `Auto | `Never ];
  25. if_then_else : [ `Compact | `Fit_or_vertical | `Keyword_first | `K_R ];
  26. indent_after_in : Ocamlformat_stdlib.int;
  27. indicate_multiline_delimiters : [ `No | `Space | `Closing_on_separate_line ];
  28. indicate_nested_or_patterns : [ `Space | `Unsafe_no ];
  29. infix_precedence : [ `Indent | `Parens ];
  30. leading_nested_match_parens : Ocamlformat_stdlib.bool;
  31. let_and : [ `Compact | `Sparse ];
  32. let_binding_indent : Ocamlformat_stdlib.int;
  33. let_binding_spacing : [ `Compact | `Sparse | `Double_semicolon ];
  34. let_module : [ `Compact | `Sparse ];
  35. line_endings : [ `Lf | `Crlf ];
  36. margin : Ocamlformat_stdlib.int;
    (*

    Format code to fit within margin columns.

    *)
  37. match_indent : Ocamlformat_stdlib.int;
  38. match_indent_nested : [ `Always | `Auto | `Never ];
  39. max_indent : Ocamlformat_stdlib.int Ocamlformat_stdlib.option;
  40. module_item_spacing : [ `Compact | `Preserve | `Sparse ];
  41. nested_match : [ `Wrap | `Align ];
  42. ocp_indent_compat : Ocamlformat_stdlib.bool;
    (*

    Try to indent like ocp-indent

    *)
  43. parens_ite : Ocamlformat_stdlib.bool;
  44. parens_tuple : [ `Always | `Multi_line_only ];
  45. parens_tuple_patterns : [ `Always | `Multi_line_only ];
  46. parse_docstrings : Ocamlformat_stdlib.bool;
  47. parse_toplevel_phrases : Ocamlformat_stdlib.bool;
  48. sequence_blank_line : [ `Compact | `Preserve_one ];
  49. sequence_style : [ `Before | `Separator | `Terminator ];
  50. single_case : [ `Compact | `Sparse ];
  51. space_around_arrays : Ocamlformat_stdlib.bool;
  52. space_around_lists : Ocamlformat_stdlib.bool;
  53. space_around_records : Ocamlformat_stdlib.bool;
  54. space_around_variants : Ocamlformat_stdlib.bool;
  55. stritem_extension_indent : Ocamlformat_stdlib.int;
  56. type_decl : [ `Compact | `Sparse ];
  57. type_decl_indent : Ocamlformat_stdlib.int;
  58. wrap_comments : Ocamlformat_stdlib.bool;
    (*

    Wrap comments at margin.

    *)
  59. wrap_fun_args : Ocamlformat_stdlib.bool;
}

Formatting options

val default_profile : fmt_opts
type file =
  1. | Stdin
  2. | File of Ocamlformat_stdlib.string
type opr_opts = {
  1. comment_check : Ocamlformat_stdlib.bool;
  2. debug : Ocamlformat_stdlib.bool;
    (*

    Generate debugging output if true.

    *)
  3. disable : Ocamlformat_stdlib.bool;
  4. margin_check : Ocamlformat_stdlib.bool;
    (*

    Check whether the formatted output exceeds the margin.

    *)
  5. max_iters : Ocamlformat_stdlib.int;
    (*

    Fail if output of formatting does not stabilize within max_iters iterations.

    *)
  6. ocaml_version : Ocaml_version.t;
    (*

    Version of OCaml syntax of the output.

    *)
  7. quiet : Ocamlformat_stdlib.bool;
  8. range : Ocamlformat_stdlib.string -> Range.t;
}

Options changing the tool's behavior

type t = {
  1. fmt_opts : fmt_opts;
  2. opr_opts : opr_opts;
}
val default : t
type input = {
  1. kind : Syntax.t;
  2. name : Ocamlformat_stdlib.string;
  3. file : file;
  4. conf : t;
}
type action =
  1. | In_out of input * Ocamlformat_stdlib.string Ocamlformat_stdlib.option
    (*

    Format input file (or - for stdin) of given kind to output file, or stdout if None.

    *)
  2. | Inplace of input Ocamlformat_stdlib.list
    (*

    Format in-place, overwriting input file(s).

    *)
  3. | Check of input Ocamlformat_stdlib.list
    (*

    Check whether the input files already are formatted.

    *)
  4. | Print_config of t
    (*

    Print the configuration and exit.

    *)
  5. | Numeric of input

update ?quiet c a updates configuration c after reading attribute a. quiet is false by default.

val print_config : t -> Ocamlformat_stdlib.unit
OCaml

Innovation. Community. Security.