Get additional lines of a todo
This commit is contained in:
parent
6f464f6700
commit
517ca459de
23
main.go
23
main.go
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
@ -11,8 +12,6 @@ import (
|
||||||
|
|
||||||
// TODO implement dynamic comment token selection
|
// TODO implement dynamic comment token selection
|
||||||
|
|
||||||
// TODO get any additional lines from the todo
|
|
||||||
|
|
||||||
// TODO With line number find if todo is in a function or struct record the name of the function / struct in `todo{}`
|
// TODO With line number find if todo is in a function or struct record the name of the function / struct in `todo{}`
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -23,6 +22,10 @@ const (
|
||||||
var (
|
var (
|
||||||
keywords = []string{"todo", "fixme"}
|
keywords = []string{"todo", "fixme"}
|
||||||
found []todo
|
found []todo
|
||||||
|
|
||||||
|
// todoMode tracks if subsequent comment lines should be included in the last to-do's description
|
||||||
|
todoMode = false
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type todo struct {
|
type todo struct {
|
||||||
|
@ -84,9 +87,25 @@ func processFilesInDir(dir string) error {
|
||||||
|
|
||||||
results := r.FindSubmatch([]byte(l))
|
results := r.FindSubmatch([]byte(l))
|
||||||
if results == nil {
|
if results == nil {
|
||||||
|
if len(l) < 3 {
|
||||||
|
todoMode = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if todoMode {
|
||||||
|
l = strings.TrimSpace(l)
|
||||||
|
if l[:2] == "//" {
|
||||||
|
found[len(found)-1].Description += "\n" + l[2:]
|
||||||
|
} else {
|
||||||
|
todoMode = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
found = append(found, todo{filepath, string(results[1]), i+1})
|
found = append(found, todo{filepath, string(results[1]), i+1})
|
||||||
|
todoMode = true
|
||||||
|
|
||||||
|
// TODO Working on getting subsequent lines of a todo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue