ocp-indent library, "newline tokens" fork
Module IndentBlock
type t

Indenter block

val shift : t -> int -> t

Shift a block by a given offset

val set_column : t -> int -> t

Set the start column of the given block to column

val reverse : t -> t

reverse block updates the stack to account for the original indentation, assumed as correct. Useful for partial indentation

val padding : t -> int

Return the padding of the block, ie expected relative indentation of sub-blocks

val indent : t -> int

Return the block indentation

val empty : t

The empty block

val update : IndentConfig.t -> t -> Nstream.t -> Nstream.token -> t

update t str tok computes the new block state after processing the token tok in block t. The next tokens can be observed in the stream str.

val dump : t -> unit

Display token and stack of the block

val guess_indent : t -> int

guess_indent line block For indenting empty lines: attempt to guess what the most probable indent at this point would be

val is_at_top : t -> bool

True only when the block is at the root of the file (the stack is empty, the block isn't included in any syntactical construct).

val is_declaration : t -> bool

Returns true if the given block is at a top-level declaration level, ie not within any expression or type definition, but possibly inside a module, signature or class definition.

val is_in_comment : t -> bool

Either we are at a comment, or within an ocamldoc block.

val is_in_string : t -> bool
val starts_line : t -> bool

true when the block is at a line start.