package ocamlformat

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

Configuration options

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

    How to potentially break string literals into new lines.

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

    Format code to fit within margin columns.

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

    Try to indent like ocp-indent

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

    Wrap comments at margin.

    *)
  62. 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;
}

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 * Ocamlformat_stdlib.int * Ocamlformat_stdlib.int
val update : ?quiet:Ocamlformat_stdlib.bool -> t -> Extended_ast.attribute -> t

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

val print_config : t -> Ocamlformat_stdlib.unit