Gutenberg

Class AllmanBracketer<T>

An IBracketer<T> which uses the Allman style.

Inheritance
Implements
Declaration
public class AllmanBracketer<T> : Object, IBracketer<T>
Type Parameters
Name Description

T

The type of annotations in the document.

Remarks

"The Allman style" is the name for the bracketing style which is customary in C#. The opening bracket is placed on a new line, the contained document is indented, and the closing bracket is placed on a new line.

Examples
var bracketer = new AllmanBracketer<object>("{", "}", false);
var doc = "header" + bracketer.Bracket(
    new Doc[] { "line 1", "line 2" }
        .Separated(Doc.LineBreak)
);
Console.WriteLine(doc);
// Output:
// header
// {
//     line 1
//     line 2
// }

Constructors

AllmanBracketer(Document<T>, Document<T>, Boolean, Nullable<Int32>)

Creates an IBracketer<T> which uses the Allman style.

Declaration
public AllmanBracketer(Document<T> openingBracket, Document<T> closingBracket, bool group = true, Nullable<int> nestingLevel = null)
Parameters
Type Name Description

Document<T>

openingBracket

A Document<T> representing the opening bracket character.

Document<T>

closingBracket

A Document<T> representing the closing bracket character.

Boolean

group

Whether the resulting Document<T> should be grouped — that is, whether the document may be flattened to a single line if it fits.

Nullable<Int32>

nestingLevel

The amount of indentation to apply to the bracketed document

Methods

Bracket(Document<T>)

Surrounds the document with brackets.

Declaration
public Document<T> Bracket(Document<T> document)
Parameters
Type Name Description

Document<T>

document

Returns
Type Description

Document<T>

Implements

IBracketer<T>