MCPcopy Create free account
hub / github.com/cel-expr/cel-go / ParseDescription

Function ParseDescription

common/doc.go:76–90  ·  view source on GitHub ↗

ParseDescription takes a single string containing newline characters and splits it into a multiline description. All empty lines will be skipped. Returns an empty string if the input string is empty.

(doc string)

Source from the content-addressed store, hash-verified

74//
75// Returns an empty string if the input string is empty.
76func ParseDescription(doc string) string {
77 var lines []string
78 if len(doc) != 0 {
79 // Split the input string by newline characters.
80 for _, line := range strings.Split(doc, "\n") {
81 l := strings.TrimRightFunc(line, unicode.IsSpace)
82 if len(l) == 0 {
83 continue
84 }
85 lines = append(lines, l)
86 }
87 }
88 // Return an empty slice if the input is empty.
89 return MultilineDescription(lines...)
90}
91
92// ParseDescriptions splits a documentation string into multiple multi-line description
93// sections, using blank lines as delimiters.

Callers 4

TestParseDescriptionFunction · 0.85
NewVariableDocFunction · 0.85
NewFunctionDocFunction · 0.85
NewMacroDocFunction · 0.85

Calls 1

MultilineDescriptionFunction · 0.85

Tested by 1

TestParseDescriptionFunction · 0.68