package ocamlformat-lib

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include module type of Conf_t
type parsed_from = [
  1. | `File of Ocaml_common.Location.t
  2. | `Attribute of Ocaml_common.Location.t
]
type updated_from = [
  1. | `Env
  2. | `Commandline
  3. | `Parsed of parsed_from
]
type from = [
  1. | `Default
  2. | `Profile of Ocamlformat_stdlib.string * updated_from
  3. | `Updated of updated_from * from Ocamlformat_stdlib.option
]
module Error : sig ... end
module Elt : sig ... end
type 'a elt = 'a Elt.t
type fmt_opts = {
  1. align_symbol_open_paren : Ocamlformat_stdlib.bool elt;
  2. assignment_operator : [ `Begin_line | `End_line ] elt;
  3. break_before_in : [ `Fit_or_vertical | `Auto ] elt;
  4. break_cases : [ `Fit | `Nested | `Toplevel | `Fit_or_vertical | `Vertical | `All ] elt;
  5. break_collection_expressions : [ `Wrap | `Fit_or_vertical ] elt;
  6. break_colon : [ `Before | `After ] elt;
  7. break_infix : [ `Wrap | `Fit_or_vertical | `Wrap_or_vertical ] elt;
  8. break_infix_before_func : Ocamlformat_stdlib.bool elt;
  9. break_fun_decl : [ `Wrap | `Fit_or_vertical | `Smart ] elt;
  10. break_fun_sig : [ `Wrap | `Fit_or_vertical | `Smart ] elt;
  11. break_separators : [ `Before | `After ] elt;
  12. break_sequences : Ocamlformat_stdlib.bool elt;
  13. break_string_literals : [ `Auto | `Never ] elt;
    (*

    How to potentially break string literals into new lines.

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

    Format code to fit within margin columns.

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

    Try to indent like ocp-indent

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

    Wrap comments at margin.

    *)
  61. wrap_fun_args : Ocamlformat_stdlib.bool elt;
}

Formatting options

type opr_opts = {
  1. comment_check : Ocamlformat_stdlib.bool elt;
  2. debug : Ocamlformat_stdlib.bool elt;
    (*

    Generate debugging output if true.

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

    Check whether the formatted output exceeds the margin.

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

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

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

    Version of OCaml syntax of the output.

    *)
  7. quiet : Ocamlformat_stdlib.bool elt;
  8. range : (Ocamlformat_stdlib.string -> Range.t) elt;
  9. disable_conf_attrs : Ocamlformat_stdlib.bool elt;
  10. version_check : Ocamlformat_stdlib.bool elt;
}

Options changing the tool's behavior

type t = {
  1. fmt_opts : fmt_opts;
  2. opr_opts : opr_opts;
  3. profile : [ `default | `conventional | `ocamlformat | `janestreet ] elt;
}
val default_profile : from -> fmt_opts
val default : t

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

val update_state : t -> [ `Enable | `Disable ] -> t
val parse_line : t -> ?version_check:Ocamlformat_stdlib.bool -> ?disable_conf_attrs:Ocamlformat_stdlib.bool -> from: [< `Attribute of Ocaml_common.Warnings.loc | `File of Ocaml_common.Warnings.loc ] -> Ocamlformat_stdlib.string -> (t, Error.t) Ocamlformat_stdlib.Result.t
val print_config : t -> Ocamlformat_stdlib.unit
val warn : loc:Ocaml_common.Warnings.loc -> ('a, Ocamlformat_stdlib.Format.formatter, Ocamlformat_stdlib.unit, Ocamlformat_stdlib.unit) Ocamlformat_stdlib.format4 -> 'a
module UI : sig ... end
module Operational : sig ... end
val term : (t -> t) Cmdliner.Term.t
val options : Conf_decl.Store.t