public void head()

in codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/DocumentationConverter.java [114:156]


        public void head(Node node, int depth) {
            String name = node.nodeName();
            if (isTopLevelCodeBlock(node, depth)) {
                writer.indent();
            }

            if (node.nodeName().equals("a")) {
                // Logic to format anchors as Go Links https://tip.golang.org/doc/comment#links
                Element element = (Element) node;
                String text = element.text();
                String url = element.absUrl("href");
                if (url.isEmpty()) {
                    // an empty anchor won't have a reference at the end, so just
                    // output it directly to the output
                    writer.writeInlineWithNoFormatting(text);
                    return;
                }
                String wrappedAnchorText = "[" + text + "]";
                writer.writeInlineWithNoFormatting(wrappedAnchorText);
                links.put(text, url);
            }

            Node parentNode = node.parentNode();
            if (parentNode != null && parentNode.nodeName().equals("a") && node instanceof TextNode) {
                // anchor tags get processed twice: once as anchor tags and another one as
                // textNodes. Since this was already processed as anchor, no need to do anything else
                return;
            }
            if (node instanceof TextNode) {
                writeText((TextNode) node);
            } else if (isTopLevelCodeBlock(node, depth)) {
                writeNewline();
                writeIndent();
            } else if (LIST_BLOCK_NODES.contains(name)) {
                listDepth++;
            } else if (name.equals("li")) {
                // We don't actually write out the list prefix here in case the list element
                // starts with one or more text blocks. By deferring writing those out until
                // the first bit of actual text, we can ensure that no intermediary newlines
                // are kept. It also has the added benefit of eliminating empty list elements.
                needsListPrefix = true;
            }
        }