Skip to content

Commit db65aa6

Browse files
committed
Apply feedback
1 parent 1460848 commit db65aa6

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

v2/codetags/extractor.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ import (
3636
// Example: When called with prefix "+k8s:", lines:
3737
//
3838
// Comment line without marker
39-
// +k8s:noArgs // comment
39+
// +k8s:noArgs # comment
4040
// +withValue=value1
4141
// +withValue=value2
4242
// +k8s:withArg(arg1)=value1
43-
// +k8s:withArg(arg2)=value2 // comment
43+
// +k8s:withArg(arg2)=value2 # comment
4444
// +k8s:withNamedArgs(arg1=value1, arg2=value2)=value
4545
//
4646
// Then this function will return:
4747
//
4848
// map[string][]string{
49-
// "noArgs": {"noArgs // comment"},
50-
// "withArg": {"withArg(arg1)=value1", "withArg(arg2)=value2 // comment"},
49+
// "noArgs": {"noArgs # comment"},
50+
// "withArg": {"withArg(arg1)=value1", "withArg(arg2)=value2 # comment"},
5151
// "withNamedArgs": {"withNamedArgs(arg1=value1, arg2=value2)=value"},
5252
// }
5353
func Extract(prefix string, lines []string) map[string][]string {

v2/codetags/parser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import (
7171
//
7272
// For example,
7373
//
74-
// "name" // no value
74+
// "name" # no value
7575
// "name=identifier"
7676
// "name="double-quoted value""
7777
// "name=`backtick-quoted value`"
@@ -85,7 +85,7 @@ import (
8585
//
8686
// For example,
8787
//
88-
// "key=value // This comment is ignored"
88+
// "key=value # This comment is ignored"
8989
//
9090
// Formal Grammar:
9191
//
@@ -217,7 +217,7 @@ func parseTag(input string, opts parseOpts) (Tag, error) {
217217
parseLoop:
218218
for r := s.peek(); r != EOF; r = s.peek() {
219219
switch st {
220-
case stTag:
220+
case stTag: // Any leading whitespace is expected to be trimmed before parsing.
221221
switch {
222222
case isIdentBegin(r):
223223
tagName, err = s.nextIdent(isTagNameInterior)

v2/codetags/scanner.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,10 @@ const (
6767
)
6868

6969
func (s *scanner) nextIsTrailingComment() bool {
70-
if s.pos >= len(s.buf)-1 {
71-
return false
70+
i := 0
71+
for ; unicode.IsSpace(s.peekN(i)); i++ {
7272
}
73-
for i := s.pos; i < len(s.buf)-1; i++ {
74-
switch {
75-
case unicode.IsSpace(s.buf[i]):
76-
continue
77-
case s.buf[i] == '#':
78-
return true
79-
default:
80-
return false
81-
}
82-
}
83-
return false
73+
return s.peekN(i) == '#'
8474
}
8575

8676
func (s *scanner) nextNumber() (string, error) {

0 commit comments

Comments
 (0)