Doc write() {
        SmithyBuilder.requiredState("open", open);
        SmithyBuilder.requiredState("close", close);
        SmithyBuilder.requiredState("children", children);
        if (forceLineBreaks) {
            return FormatVisitor.renderBlock(open, close, Doc.intersperse(Doc.line(), children));
        }

        int indent = forceInline ? 0 : 4;
        Doc lineBreakDoc = getBracketLineBreakDoc();
        return Doc.intersperse(Formatter.LINE_OR_COMMA, children).bracket(indent, lineBreakDoc, open, close);
    }
Formats various kinds of brackets, dealing with interspersed whitespace and comments.
smithy-syntax/src/main/java/software/amazon/smithy/syntax/BracketFormatter.java