Get additional lines of a todo

This commit is contained in:
Samuel Hawksby-Robinson 2021-01-05 13:23:07 +00:00
parent 6f464f6700
commit 517ca459de
No known key found for this signature in database
GPG Key ID: 64CF99D4A64A1205
1 changed files with 21 additions and 2 deletions

23
main.go
View File

@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"regexp"
"strings"
"unicode"
"github.com/davecgh/go-spew/spew"
@ -11,8 +12,6 @@ import (
// 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{}`
const (
@ -23,6 +22,10 @@ const (
var (
keywords = []string{"todo", "fixme"}
found []todo
// todoMode tracks if subsequent comment lines should be included in the last to-do's description
todoMode = false
)
type todo struct {
@ -84,9 +87,25 @@ func processFilesInDir(dir string) error {
results := r.FindSubmatch([]byte(l))
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
}
found = append(found, todo{filepath, string(results[1]), i+1})
todoMode = true
// TODO Working on getting subsequent lines of a todo
}
}