Skip to content

Commit

Permalink
supports multiple language comment(only oneliner)
Browse files Browse the repository at this point in the history
  • Loading branch information
takashi committed Apr 24, 2014
1 parent 7358fdb commit c444c61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var LangList []*Lang
func init() {
LangList = []*Lang{
LangRuby,
LangJs,
}
}

Expand Down
5 changes: 3 additions & 2 deletions lang_rb.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

var LangRuby = &Lang{
Name: "ruby",
Ext: ".rb",
Name: "Ruby",
Ext: ".rb",
OneLineComment: "#",
}
10 changes: 7 additions & 3 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,27 @@ func WalkFn(path string, info os.FileInfo, err error) error {
} else if info.IsDir() {
// do nothing
} else {
ParseIssues(path string, info os.FileInfo)
err := ParseIssues(path, info)
if err != nil {
return err
}
}
return nil
}

func ParseIssues() {
func ParseIssues(path string, info os.FileInfo) error {
// do the file parse here
lang := DetectLangFromExt(filepath.Ext(path))
if lang != nil {
body, err := ioutil.ReadFile(path)
if err != nil {
return err
}
re, _ := regexp.Compile(`# \[TODO\].*`)
re, _ := regexp.Compile(lang.OneLineComment + ` \[TODO\].*`)
one := re.Find(body)
if one != nil {
fmt.Printf("Find a TODO: %s \n at %s\n", one, path)
}
}
return nil
}

0 comments on commit c444c61

Please sign in to comment.