private static String capture(DocWriter writer, Consumer<DocWriter> consumer) {
        var recorder = new RecordingInterceptor();
        writer.pushState(new CapturingSection()).onSection(recorder);
        consumer.accept(writer);
        writer.popState();
        return recorder.getContents();
    }
Captures and returns what is written by the given consumer.

@param writer The writer to capture from.
@param consumer A consumer that writes text to be captured.
@return Returns what was written by the consumer.
smithy-docgen/src/main/java/software/amazon/smithy/docgen/generators/GeneratorUtils.java