func()

in tools/diff-processor/documentparser/document_parser.go [68:103]


func (d *DocumentParser) Parse(src []byte) error {
	var argument, attribute string
	for _, p := range strings.Split(string(src), "\n"+sectionSeparator) {
		if strings.HasPrefix(p, "Attributes Reference") {
			attribute = p
		}
		if strings.HasPrefix(p, "Argument Reference") {
			argument = p
		}
	}
	for _, text := range []string{argument, attribute} {
		if len(text) != 0 {
			sections := horizontalLineRegex.Split(text, -1)
			var allTopLevelFieldSections string
			for _, part := range sections {
				topLevelPropertySection, err := d.extractNestedObject(part)
				if err != nil {
					return err
				}
				allTopLevelFieldSections += topLevelPropertySection
			}
			root := &node{
				text: allTopLevelFieldSections,
			}
			if err := d.bfs(root, d.nestedBlock); err != nil {
				return err
			}
			if d.root == nil {
				d.root = root
			} else {
				d.root.children = append(d.root.children, root.children...)
			}
		}
	}
	return nil
}