package indentation_buffer

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

Module Indentation_bufferSource

Sourcetype t

A buffer that keeps track of the current indentation level. It abstracts the need for formatting code to thread the current indentation everywhere, and also ensures that blank lines do not accidentally get filled with the current indentation, thus yielding trailing whitespace in the output.

Sourceval string : t -> string -> unit

Appends the input string to a buffer. If the buffer is at the start of a new line, then the current indentation is inserted.

Sourceval newline : t -> unit

Starts a new line in the buffer, but does not append any indentation. This will only happen if a string is appended before the buffer moves to the next line.

Sourceval indent : t -> unit

Increase the current indentation by one level.

Sourceval dedent : t -> unit

Decrease the current indentation by one level.

Sourceval create : int -> t

Create a new buffer with the specified initial capacity.

Sourceval contents : t -> string

Retrieve the contents of the buffer as a string.

OCaml

Innovation. Community. Security.