Skip to content

Commit

Permalink
keep empty lines while parsing comments (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasJenicek committed Apr 8, 2024
1 parent 0e4e294 commit 3f48bd0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions _examples/golang-basics/example.gen.go

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

4 changes: 3 additions & 1 deletion _examples/golang-basics/example.ridl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ enum Intent: string

struct Empty


# User struct
#
# More information about user struct
struct User
- id: uint64
+ json = id
Expand Down
8 changes: 6 additions & 2 deletions schema/ridl/ridl.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func (p *Parser) parse() (*schema.WebRPCSchema, error) {
StreamOutput: method.StreamOutput(),
Inputs: inputs,
Outputs: outputs,
Comments: strings.FieldsFunc(method.Comment(), func(r rune) bool { return r == '\n' }),
Comments: parseComment(method.Comment()),
}

methods = append(methods, m)
Expand Down Expand Up @@ -358,5 +358,9 @@ func buildArgumentsList(s *schema.WebRPCSchema, args []*ArgumentNode) ([]*schema
}

func parseComment(comment string) []string {
return strings.FieldsFunc(comment, func(r rune) bool { return r == '\n' })
if comment == "" {
return []string{}
}

return strings.Split(comment, "\n")
}

0 comments on commit 3f48bd0

Please sign in to comment.