private static void writeProtocolSection(
            DocGenerationContext context,
            DocWriter writer,
            Shape shape,
            ShapeId protocol
    ) {
        var protocolSymbol = context.symbolProvider().toSymbol(context.model().expectShape(protocol));

        AtomicReference<String> tabContents = new AtomicReference<>();
        var tab = capture(writer, tabWriter -> {
            tabWriter.openTab(protocolSymbol.getName());
            tabContents.set(capture(tabWriter,
                    w2 -> tabWriter.injectSection(
                            new ProtocolSection(context, shape, protocol))));
            tabWriter.closeTab();
        });

        if (StringUtils.isBlank(tabContents.get())) {
            // The extra newline is needed because the section intercepting logic actually adds one
            // by virtue of calling write instead of writeInline
            writer.unwrite("$L\n", tab);
        }
    }
Provides common generation methods for services and resources.
smithy-docgen/src/main/java/software/amazon/smithy/docgen/generators/GeneratorUtils.java