Skip to content

Commit

Permalink
docs: flatten multiline comments
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov committed Jun 19, 2024
1 parent c8292c8 commit b754897
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 183 deletions.
12 changes: 10 additions & 2 deletions generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,14 @@ func writeStruct(f *jen.File, s *Schema) error {

// Adds a comment if it's not equal to the field name
if p.Description != "" && p.Description != p.CamelName {
field = field.Add(jen.Comment(p.Description))
field = field.Add(jen.Comment(fmtComment(p.Description)))
}

fields = append(fields, field)
}

if s.Description != "" {
f.Comment(fmt.Sprintf("%s %s", s.CamelName, s.Description))
f.Comment(fmt.Sprintf("%s %s", s.CamelName, fmtComment(s.Description)))
}

f.Type().Id(s.CamelName).Struct(fields...)
Expand Down Expand Up @@ -539,3 +539,11 @@ func readConfig(path string) (map[string][]string, error) {

return c, nil
}

// reComment replaces new lines and trailing period,
// which is added in fmtComment as a separater
var reComment = regexp.MustCompile(`\.?[\r\n]+\s*?`)

func fmtComment(c string) string {
return reComment.ReplaceAllString(c, ". ")
}
46 changes: 11 additions & 35 deletions handler/kafkamirrormaker/kafkamirrormaker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 24 additions & 72 deletions handler/privatelink/privatelink.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b754897

Please sign in to comment.