mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 21:53:52 +00:00
Strip go2idl instructions from generated swagger doc
Ignore doc lines starting with +
This commit is contained in:
@@ -65,11 +65,14 @@ func fmtRawDoc(rawDoc string) string {
|
|||||||
|
|
||||||
for _, line := range strings.Split(rawDoc, "\n") {
|
for _, line := range strings.Split(rawDoc, "\n") {
|
||||||
line = strings.TrimRight(line, " ")
|
line = strings.TrimRight(line, " ")
|
||||||
|
leading := strings.TrimLeft(line, " ")
|
||||||
if line == "" { // Keep paragraphs
|
switch {
|
||||||
|
case len(line) == 0: // Keep paragraphs
|
||||||
delPrevChar()
|
delPrevChar()
|
||||||
buffer.WriteString("\n\n")
|
buffer.WriteString("\n\n")
|
||||||
} else if !strings.HasPrefix(strings.TrimLeft(line, " "), "TODO") { // Ignore one line TODOs
|
case strings.HasPrefix(leading, "TODO"): // Ignore one line TODOs
|
||||||
|
case strings.HasPrefix(leading, "+"): // Ignore instructions to go2idl
|
||||||
|
default:
|
||||||
if strings.HasPrefix(line, " ") || strings.HasPrefix(line, "\t") {
|
if strings.HasPrefix(line, " ") || strings.HasPrefix(line, "\t") {
|
||||||
delPrevChar()
|
delPrevChar()
|
||||||
line = "\n" + line + "\n" // Replace it with newline. This is useful when we have a line with: "Example:\n\tJSON-someting..."
|
line = "\n" + line + "\n" // Replace it with newline. This is useful when we have a line with: "Example:\n\tJSON-someting..."
|
||||||
|
Reference in New Issue
Block a user