Skip to content

Commit

Permalink
skip comment when its 2 lines above (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasJenicek committed Apr 15, 2024
1 parent bc14da9 commit c4ba018
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions schema/ridl/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,12 @@ func parseComments(comments map[int]string, currentLine int) string {
break
}

iteration++

// if there are 2 lines of empty space => no comment we don't read more lines
if iteration > 1 {
break
}

iteration++
}

if len(c) > 0 {
Expand Down
4 changes: 4 additions & 0 deletions schema/ridl/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,9 @@ func TestParseServiceComments(t *testing.T) {
#! skip more lines
#! more
- Version() => (details: any)
# test comment two lines above
- Version2() => (details: any)
`)
assert.NoError(t, err)

Expand All @@ -1018,4 +1021,5 @@ func TestParseServiceComments(t *testing.T) {
assert.Equal(t, "Contacts service line 1\nContacts service line 2\nContacts service line 3", serviceNode.comment)
assert.Equal(t, "GetContact gives you contact for specific id\nsee https://www.example.com/?first=1&second=12#help", serviceNode.methods[0].comment)
assert.Equal(t, "Version returns you current deployed version\n", serviceNode.methods[1].comment)
assert.Equal(t, "", serviceNode.methods[2].comment)
}

0 comments on commit c4ba018

Please sign in to comment.