INNER CODE UNIT · Go
formatDescription
kubernetes-sigs/gateway-api · tools/generator/main.go:384
func formatDescription(description string, channel string, name string) string {
startTag := "<gateway:experimental:description>"
endTag := "</gateway:experimental:description>"
if channel == "standard" && strings.Contains(description, "<gateway:experimental:description>") {
regexPattern := `\n*` + regexp.QuoteMeta(startTag) + `(?s:(.*?))` + regexp.QuoteMeta(endTag) + `\n*`
re := regexp.MustCompile(regexPattern)
match := re.FindStringSubmatch(description)
if len(match) != 2 {
log.Fatalf("Invalid <gateway:experimental:description> tag for %s", name)
}
description = re.ReplaceAllString(description, "\n\n")
} else {
description = strings.ReplaceAll(description, startTag, "")
description = strings.ReplaceAll(description, endTag, "")
}
// Comments within "gateway:util:excludeFromCRD" tag is not included in the generated CRD and all trailing \n operators before
// and after the tags are removed and replaced with three \n operators.