t.Funcs(template.FuncMap{
"node": nodeFmt,
"synopsis": synopsisFmt,
+ "indent": indentFmt,
})
return template.Must(t.ParseFiles(filepath.Join(dataDir, filename)))
}
return "// " + strings.Replace(s, "\n", " ", -1)
}
+func indentFmt(indent, s string) string {
+ end := ""
+ if strings.HasSuffix(s, "\n") {
+ end = "\n"
+ s = s[:len(s)-1]
+ }
+ return indent + strings.Replace(s, "\n", "\n"+indent, -1) + end
+}
+
func isGoFile(fi os.FileInfo) bool {
name := fi.Name()
return !fi.IsDir() &&
// We remove any formatting so that we don't
// get spurious line breaks/indentation when
// showing the TODO body.
- body := clean(text[m[1]:])
+ body := clean(text[m[1]:], keepNL)
if body != "" {
marker := text[m[2]:m[3]]
r.notes[marker] = append(r.notes[marker], &Note{
return len(s)
}
+const (
+ keepNL = 1 << iota
+)
+
// clean replaces each sequence of space, \n, \r, or \t characters
// with a single space and removes any trailing and leading spaces.
-func clean(s string) string {
+// If the keepNL flag is set, newline characters are passed through
+// instead of being change to spaces.
+func clean(s string, flags int) string {
var b []byte
p := byte(' ')
for i := 0; i < len(s); i++ {
q := s[i]
- if q == '\n' || q == '\r' || q == '\t' {
+ if (flags&keepNL) == 0 && q == '\n' || q == '\r' || q == '\t' {
q = ' '
}
if q != ' ' || p != ' ' {
// is the empty string.
//
func Synopsis(s string) string {
- s = clean(s[0:firstSentenceLen(s)])
+ s = clean(s[0:firstSentenceLen(s)], 0)
for _, prefix := range IllegalPrefixes {
if strings.HasPrefix(strings.ToLower(s), prefix) {
return ""
testdata/a1.go
BUGS .Bugs is now deprecated, please use .Notes instead
- // bug0
- // bug1
+ bug0
+
+ bug1
+
BUGS
- // bug0 (uid: uid)
- // bug1 (uid: uid)
+BUG(uid) bug0
+
+BUG(uid) bug1
+
NOTES
- // 1 of 4 - this is the first line of note 1 - note 1 continues on ... (uid: foo)
- // 2 of 4 (uid: foo)
- // 3 of 4 (uid: bar)
- // 4 of 4 - this is the last line of note 4 (uid: bar)
- // This note which contains a (parenthesized) subphrase must ... (uid: bam)
- // The ':' after the marker and uid is optional. (uid: xxx)
+NOTE(uid)
+
+NOTE(foo) 1 of 4 - this is the first line of note 1
+ - note 1 continues on this 2nd line
+ - note 1 continues on this 3rd line
+
+NOTE(foo) 2 of 4
+
+NOTE(bar) 3 of 4
+
+NOTE(bar) 4 of 4
+ - this is the last line of note 4
+
+NOTE(bam) This note which contains a (parenthesized) subphrase
+ must appear in its entirety.
+
+NOTE(xxx) The ':' after the marker and uid is optional.
+
SECBUGS
- // sec hole 0 need to fix asap (uid: uid)
+SECBUG(uid) sec hole 0
+ need to fix asap
+
TODOS
- // todo0 (uid: uid)
- // todo1 (uid: uid)
+TODO(uid) todo0
+
+TODO(uid) todo1
+
testdata/a1.go
BUGS .Bugs is now deprecated, please use .Notes instead
- // bug0
- // bug1
+ bug0
+
+ bug1
+
BUGS
- // bug0 (uid: uid)
- // bug1 (uid: uid)
+BUG(uid) bug0
+
+BUG(uid) bug1
+
NOTES
- // 1 of 4 - this is the first line of note 1 - note 1 continues on ... (uid: foo)
- // 2 of 4 (uid: foo)
- // 3 of 4 (uid: bar)
- // 4 of 4 - this is the last line of note 4 (uid: bar)
- // This note which contains a (parenthesized) subphrase must ... (uid: bam)
- // The ':' after the marker and uid is optional. (uid: xxx)
+NOTE(uid)
+
+NOTE(foo) 1 of 4 - this is the first line of note 1
+ - note 1 continues on this 2nd line
+ - note 1 continues on this 3rd line
+
+NOTE(foo) 2 of 4
+
+NOTE(bar) 3 of 4
+
+NOTE(bar) 4 of 4
+ - this is the last line of note 4
+
+NOTE(bam) This note which contains a (parenthesized) subphrase
+ must appear in its entirety.
+
+NOTE(xxx) The ':' after the marker and uid is optional.
+
SECBUGS
- // sec hole 0 need to fix asap (uid: uid)
+SECBUG(uid) sec hole 0
+ need to fix asap
+
TODOS
- // todo0 (uid: uid)
- // todo1 (uid: uid)
+TODO(uid) todo0
+
+TODO(uid) todo1
+
testdata/a1.go
BUGS .Bugs is now deprecated, please use .Notes instead
- // bug0
- // bug1
+ bug0
+
+ bug1
+
BUGS
- // bug0 (uid: uid)
- // bug1 (uid: uid)
+BUG(uid) bug0
+
+BUG(uid) bug1
+
NOTES
- // 1 of 4 - this is the first line of note 1 - note 1 continues on ... (uid: foo)
- // 2 of 4 (uid: foo)
- // 3 of 4 (uid: bar)
- // 4 of 4 - this is the last line of note 4 (uid: bar)
- // This note which contains a (parenthesized) subphrase must ... (uid: bam)
- // The ':' after the marker and uid is optional. (uid: xxx)
+NOTE(uid)
+
+NOTE(foo) 1 of 4 - this is the first line of note 1
+ - note 1 continues on this 2nd line
+ - note 1 continues on this 3rd line
+
+NOTE(foo) 2 of 4
+
+NOTE(bar) 3 of 4
+
+NOTE(bar) 4 of 4
+ - this is the last line of note 4
+
+NOTE(bam) This note which contains a (parenthesized) subphrase
+ must appear in its entirety.
+
+NOTE(xxx) The ':' after the marker and uid is optional.
+
SECBUGS
- // sec hole 0 need to fix asap (uid: uid)
+SECBUG(uid) sec hole 0
+ need to fix asap
+
TODOS
- // todo0 (uid: uid)
- // todo1 (uid: uid)
+TODO(uid) todo0
+
+TODO(uid) todo1
+
--- /dev/null
+//
+PACKAGE bugpara
+
+IMPORTPATH
+ testdata/bugpara
+
+FILENAMES
+ testdata/bugpara.go
+
+BUGS .Bugs is now deprecated, please use .Notes instead
+ Sometimes bugs have multiple paragraphs.
+
+ Like this one.
+
+
+BUGS
+BUG(rsc) Sometimes bugs have multiple paragraphs.
+
+ Like this one.
+
--- /dev/null
+//
+PACKAGE bugpara
+
+IMPORTPATH
+ testdata/bugpara
+
+FILENAMES
+ testdata/bugpara.go
+
+BUGS .Bugs is now deprecated, please use .Notes instead
+ Sometimes bugs have multiple paragraphs.
+
+ Like this one.
+
+
+BUGS
+BUG(rsc) Sometimes bugs have multiple paragraphs.
+
+ Like this one.
+
--- /dev/null
+//
+PACKAGE bugpara
+
+IMPORTPATH
+ testdata/bugpara
+
+FILENAMES
+ testdata/bugpara.go
+
+BUGS .Bugs is now deprecated, please use .Notes instead
+ Sometimes bugs have multiple paragraphs.
+
+ Like this one.
+
+
+BUGS
+BUG(rsc) Sometimes bugs have multiple paragraphs.
+
+ Like this one.
+
--- /dev/null
+package bugpara
+
+// BUG(rsc): Sometimes bugs have multiple paragraphs.
+//
+// Like this one.
*/}}{{with .Bugs}}
BUGS .Bugs is now deprecated, please use .Notes instead
-{{range .}} {{synopsis .}}
+{{range .}}{{indent "\t" .}}
{{end}}{{end}}{{with .Notes}}{{range $marker, $content := .}}
{{$marker}}S
-{{range $content}} {{synopsis .Body}} (uid: {{.UID}})
+{{range $content}}{{$marker}}({{.UID}}){{indent "\t" .Body}}
{{end}}{{end}}{{end}}
\ No newline at end of file