package ocamlformat

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

Configuration options

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

    How to potentially break string literals into new lines.

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

    Format code to fit within margin columns.

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

    Try to indent like ocp-indent

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

    Wrap comments at margin.

    *)
  60. 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.