func checkSectionLinks()

in cqlprotodoc/main.go [111:131]


func checkSectionLinks(d spec.Document, sectionNumbers, tocNumbers map[string]struct{}) {

	for _, t := range d.TOC {
		if _, ok := sectionNumbers[t.Number]; !ok {
			fmt.Fprintf(os.Stderr, "section %q exists in TOC, but not in sections\n", t.Number)
		}
	}
	for _, s := range d.Sections {
		if _, ok := tocNumbers[s.Number]; !ok {
			fmt.Fprintf(os.Stderr, "section %q exists in sections, but not in TOC\n", s.Number)
		}
		for _, tt := range s.Body {
			if tt.SectionRef != "" {
				if _, ok := sectionNumbers[tt.SectionRef]; !ok {
					fmt.Fprintf(os.Stderr, "non-existing section %q is referenced from section %q\n",
						tt.SectionRef, s.Number)
				}
			}
		}
	}
}