package sexp_pretty

  1. Overview
  2. Docs

Module Sexp_pretty.ConfigSource

Sourcetype color =
  1. | Black
  2. | Red
  3. | Green
  4. | Yellow
  5. | Blue
  6. | Magenta
  7. | Cyan
  8. | White
  9. | Default
Sourceval sexp_of_color : color -> Sexplib0.Sexp.t
Sourceval color_of_sexp : Sexplib0.Sexp.t -> color
Sourcetype atom_threshold =
  1. | Atom_threshold of Base.int

Datatypes of various thresholds

Sourceval sexp_of_atom_threshold : atom_threshold -> Sexplib0.Sexp.t
Sourceval atom_threshold_of_sexp : Sexplib0.Sexp.t -> atom_threshold
Sourcetype char_threshold =
  1. | Character_threshold of Base.int
Sourceval sexp_of_char_threshold : char_threshold -> Sexplib0.Sexp.t
Sourceval char_threshold_of_sexp : Sexplib0.Sexp.t -> char_threshold
Sourcetype depth_threshold =
  1. | Depth_threshold of Base.int

Depth is the depth of an atom. For example, in (a (b (c) d)), the depth of a is 1, the depth of b and d is 2, and depth of c is 3. Depth_threshold usually refers to the maximum depth of any atom in a list for it to be considered for certain heuristic, e.g. data alignment.

Sourceval sexp_of_depth_threshold : depth_threshold -> Sexplib0.Sexp.t
Sourceval depth_threshold_of_sexp : Sexplib0.Sexp.t -> depth_threshold
Sourcetype aligned_parens =
  1. | Parens_alignment of Base.bool

Whether or not should closing parentheses be aligned.

Sourceval sexp_of_aligned_parens : aligned_parens -> Sexplib0.Sexp.t
Sourceval aligned_parens_of_sexp : Sexplib0.Sexp.t -> aligned_parens
Sourcetype data_alignment =
  1. | Data_not_aligned
  2. | Data_aligned of aligned_parens * atom_threshold * char_threshold * depth_threshold
    (*

    Character threshold is excluding spaces and parentheses, the maximum depth can't exceed the depth threshold.

    *)
Sourceval sexp_of_data_alignment : data_alignment -> Sexplib0.Sexp.t
Sourceval data_alignment_of_sexp : Sexplib0.Sexp.t -> data_alignment
Sourcetype atom_coloring =
  1. | Color_first of Base.int
    (*

    Color the first one, only if the number of atoms that follow it at most the value of the constructor's argument.

    *)
  2. | Color_all
  3. | Color_none
Sourceval sexp_of_atom_coloring : atom_coloring -> Sexplib0.Sexp.t
Sourceval atom_coloring_of_sexp : Sexplib0.Sexp.t -> atom_coloring
Sourcetype comment_indent =
  1. | Auto_indent_comment
  2. | Indent_comment of Base.int

This currently relates only to block comments. Auto_indent tries to infer the indentation from the original formatting, Indent_comment n indents new lines in a block comment by n spaces.

Sourceval sexp_of_comment_indent : comment_indent -> Sexplib0.Sexp.t
Sourceval comment_indent_of_sexp : Sexplib0.Sexp.t -> comment_indent
Sourcetype comment_print_style =
  1. | Pretty_print
    (*

    Auto aligns multi-line block comments.

    *)
  2. | Conservative_print
    (*

    Leaves block comments as they are, only adjusts indentation.

    *)
Sourceval all_of_comment_print_style : comment_print_style Base.list
Sourceval sexp_of_comment_print_style : comment_print_style -> Sexplib0.Sexp.t
Sourceval comment_print_style_of_sexp : Sexplib0.Sexp.t -> comment_print_style
Sourcetype comments =
  1. | Drop
  2. | Print of comment_indent * color Base.option * comment_print_style

Comment treatment.

Sourceval sexp_of_comments : comments -> Sexplib0.Sexp.t
Sourceval comments_of_sexp : Sexplib0.Sexp.t -> comments
Sourcetype atom_printing =
  1. | Escaped
    (*

    Can be parsed again. Atoms are printed out as loaded, with escaping.

    *)
  2. | Minimal_escaping
    (*

    As Escaped, but applies escaping to fewer characters.

    *)
  3. | Interpreted
    (*

    Try to interpret atoms as sexps.

    *)
Sourceval sexp_of_atom_printing : atom_printing -> Sexplib0.Sexp.t
Sourceval atom_printing_of_sexp : Sexplib0.Sexp.t -> atom_printing
Sourcetype singleton_limit =
  1. | Singleton_limit of atom_threshold * char_threshold

Singleton_lists are lists of the following format

(ATOM_1 .. ATOM_N (....))

and are printed in the following way if they are too big to fit on a line/force a breakline for other reasons:

(ATOM_1 .. ATOM_N ( .... ))

Thresholds correspond to what's an acceptable number/size of the leading atoms ATOM_1 through ATOM_N.

Character threshold is excluding spaces.

Sourceval sexp_of_singleton_limit : singleton_limit -> Sexplib0.Sexp.t
Sourceval singleton_limit_of_sexp : Sexplib0.Sexp.t -> singleton_limit
Sourcetype paren_coloring = Base.bool

Should parentheses be colored?

Sourceval sexp_of_paren_coloring : paren_coloring -> Sexplib0.Sexp.t
Sourceval paren_coloring_of_sexp : Sexplib0.Sexp.t -> paren_coloring
Sourcetype separator =
  1. | No_separator
  2. | Empty_line

Separator between individual sexps.

Sourceval sexp_of_separator : separator -> Sexplib0.Sexp.t
Sourceval separator_of_sexp : Sexplib0.Sexp.t -> separator
Sourcetype parens =
  1. | Same_line
  2. | New_line

Should closing parentheses be on the same line as the last sexp in the list (modulo comments), or should they be on new lines? Should opening parentheses always be on the same line as what follows them, or should they sometimes (when the first item in the list is a list followed by some other sexp) be on a separate line?

Sourceval sexp_of_parens : parens -> Sexplib0.Sexp.t
Sourceval parens_of_sexp : Sexplib0.Sexp.t -> parens
Sourcetype sticky_comments =
  1. | Before
  2. | Same_line
  3. | After

Where to put line comments relative to an associated sexp.

Sourceval sexp_of_sticky_comments : sticky_comments -> Sexplib0.Sexp.t
Sourceval sticky_comments_of_sexp : Sexplib0.Sexp.t -> sticky_comments
Sourcetype t = {
  1. indent : Base.int;
  2. data_alignment : data_alignment;
  3. color_scheme : color Base.array;
  4. atom_coloring : atom_coloring;
  5. atom_printing : atom_printing;
  6. paren_coloring : paren_coloring;
  7. opening_parens : parens;
  8. closing_parens : parens;
  9. comments : comments;
  10. singleton_limit : singleton_limit;
  11. leading_threshold : atom_threshold * char_threshold;
  12. separator : separator;
  13. sticky_comments : sticky_comments;
}
include Sexplib0.Sexpable.S with type t := t
Sourceval t_of_sexp : Sexplib0.Sexp.t -> t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval default : t
Sourceval create : ?color:Base.bool -> ?interpret_atom_as_sexp:Base.bool -> ?drop_comments:Base.bool -> ?new_line_separator:Base.bool -> ?custom_data_alignment:data_alignment -> Base.unit -> t
Sourceval update : ?color:Base.bool -> ?interpret_atom_as_sexp:Base.bool -> ?drop_comments:Base.bool -> ?new_line_separator:Base.bool -> ?custom_data_alignment:data_alignment -> t -> t
OCaml

Innovation. Community. Security.