Skip to content

Commit

Permalink
Ignore lines with a .PHONY prefix
Browse files Browse the repository at this point in the history
Closes tj#24
  • Loading branch information
tryzniak committed Nov 23, 2017
1 parent 3513f38 commit c0318a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ func (p *Parser) parse() error {
switch {
case p.i == len(p.lines)-1:
return nil
case strings.HasPrefix(p.peek(), ".PHONY"):
p.advance()
case len(p.peek()) == 0:
p.pushComment()
p.advance()
Expand Down
7 changes: 7 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ size:
@gopher-count /tmp/out.js | sort -nr
.PHONY: size
.PHONY: dummy
# Just a comment.
# Just another comment.
dummy:
@ls
`

p := parser.New()
Expand All @@ -63,6 +69,7 @@ size:
// parser.Comment{Target:"api", Value:"Start the API server."}
// parser.Comment{Target:"deps", Value:"Display dependency graph."}
// parser.Comment{Target:"size", Value:"Display size of dependencies.\n\n- foo\n- bar\n- baz"}
// parser.Comment{Target:"dummy", Value:"Just a comment.\nJust another comment."}
}

func ExampleParser_Parse_withoutComments() {
Expand Down

0 comments on commit c0318a7

Please sign in to comment.