MCPcopy
hub / github.com/go-yaml/yaml / fprintComments

Function fprintComments

node_test.go:2851–2880  ·  view source on GitHub ↗
(out io.Writer, node *yaml.Node, indent string)

Source from the content-addressed store, hash-verified

2849}
2850
2851func fprintComments(out io.Writer, node *yaml.Node, indent string) {
2852 switch node.Kind {
2853 case yaml.ScalarNode:
2854 fmt.Fprintf(out, "%s<%s> ", indent, node.Value)
2855 fprintCommentSet(out, node)
2856 fmt.Fprintf(out, "\n")
2857 case yaml.DocumentNode:
2858 fmt.Fprintf(out, "%s<DOC> ", indent)
2859 fprintCommentSet(out, node)
2860 fmt.Fprintf(out, "\n")
2861 for i := 0; i < len(node.Content); i++ {
2862 fprintComments(out, node.Content[i], indent+" ")
2863 }
2864 case yaml.MappingNode:
2865 fmt.Fprintf(out, "%s<MAP> ", indent)
2866 fprintCommentSet(out, node)
2867 fmt.Fprintf(out, "\n")
2868 for i := 0; i < len(node.Content); i += 2 {
2869 fprintComments(out, node.Content[i], indent+" ")
2870 fprintComments(out, node.Content[i+1], indent+" ")
2871 }
2872 case yaml.SequenceNode:
2873 fmt.Fprintf(out, "%s<SEQ> ", indent)
2874 fprintCommentSet(out, node)
2875 fmt.Fprintf(out, "\n")
2876 for i := 0; i < len(node.Content); i++ {
2877 fprintComments(out, node.Content[i], indent+" ")
2878 }
2879 }
2880}
2881
2882func fprintCommentSet(out io.Writer, node *yaml.Node) {
2883 if len(node.HeadComment)+len(node.LineComment)+len(node.FootComment) > 0 {

Callers 1

TestNodeRoundtripMethod · 0.85

Calls 1

fprintCommentSetFunction · 0.85

Tested by

no test coverage detected