<dd> <a href="#{{$tname_html}}.{{$name_html}}">{{node_html .Decl $.FSet}}</a></dd>
{{end}}
{{end}}
- {{if .Bugs}}
- <dd><a href="#pkg-bugs">Bugs</a></dd>
- {{end}}
- {{if .Notes}}
- {{range $marker, $item := .Notes}}
- <dd><a href="#pkg-{{$marker}}">{{$marker}}</a></dd>
+ {{if $.Notes}}
+ {{range $marker, $item := $.Notes}}
+ <dd><a href="#pkg-note-{{$marker}}">{{noteTitle $marker | html}}s</a></dd>
{{end}}
{{end}}
</dl>
{{comment_html .Doc}}
{{end}}
- {{with .Bugs}}
- <h2 id="pkg-bugs">Bugs</h2>
- {{range .}}
- {{comment_html .}}
- {{end}}
- {{end}}
- {{with .Notes}}
+ {{with $.Notes}}
{{range $marker, $content := .}}
- <h2 id="pkg-{{$marker}}">{{$marker}}</h2>
+ <h2 id="pkg-note-{{$marker}}">{{noteTitle $marker | html}}s</h2>
{{range .}}
{{comment_html .}}
{{end}}
---------------------------------------
-*/}}{{with .Bugs}}
-BUGS
-
-{{range .}}{{comment_text . " " "\t"}}
-{{end}}{{end}}{{with .Notes}}
+*/}}{{with $.Notes}}
{{range $marker, $content := .}}
-{{$marker}}
+{{noteTitle $marker}}s
{{range $content}}{{comment_text . " " "\t"}}
{{end}}{{end}}{{end}}{{end}}{{/*
return suffix
}
+func noteTitle(note string) string {
+ return strings.Title(strings.ToLower(note))
+}
+
func splitExampleName(s string) (name, suffix string) {
i := strings.LastIndex(s, "_")
if 0 <= i && i < len(s)-1 && !startsWithUppercase(s[i+1:]) {
"example_text": example_textFunc,
"example_name": example_nameFunc,
"example_suffix": example_suffixFunc,
+
+ // formatting of Notes
+ "noteTitle": noteTitle,
}
func readTemplate(name string) *template.Template {
Err error // error or nil
// package info
- FSet *token.FileSet // nil if no package documentation
- PDoc *doc.Package // nil if no package documentation
- Examples []*doc.Example // nil if no example code
- PAst *ast.File // nil if no AST with package exports
- IsMain bool // true for package main
+ FSet *token.FileSet // nil if no package documentation
+ PDoc *doc.Package // nil if no package documentation
+ Examples []*doc.Example // nil if no example code
+ Notes map[string][]string // nil if no package Notes
+ PAst *ast.File // nil if no AST with package exports
+ IsMain bool // true for package main
// directory info
Dirs *DirList // nil if no directory information
log.Println("parsing examples:", err)
}
info.Examples = collectExamples(pkg, files)
+
+ // collect any notes that we want to show
+ if info.PDoc.Notes != nil {
+ info.Notes = make(map[string][]string)
+ for _, m := range notesToShow {
+ if n := info.PDoc.Notes[m]; n != nil {
+ info.Notes[m] = n
+ }
+ }
+ }
+
} else {
// show source code
// TODO(gri) Consider eliminating export filtering in this mode,
// command-line searches
query = flag.Bool("q", false, "arguments are considered search queries")
+
+ // which code 'Notes' to show.
+ notes = flag.String("notes", "BUG", "comma separated list of Note markers as per pkg:go/doc")
+ // vector of 'Notes' to show.
+ notesToShow []string
)
func serveError(w http.ResponseWriter, r *http.Request, relpath string, err error) {
flag.Usage = usage
flag.Parse()
+ notesToShow = strings.Split(*notes, ",")
+
// Check usage: either server and no args, command line and args, or index creation mode
if (*httpAddr != "" || *urlFlag != "") != (flag.NArg() == 0) && !*writeIndex {
usage()
ImportPath string
Imports []string
Filenames []string
- Bugs []string
+ // DEPRECATED. For backward compatibility Bugs is still populated,
+ // but all new code should use Notes instead.
+ Bugs []string
+
// Notes such as TODO(userid): or SECURITY(userid):
// along the lines of BUG(userid). Any marker with 2 or more upper
// case [A-Z] letters is recognised.
// non-empty MARKER comment; collect comment without the MARKER prefix
list := append([]*ast.Comment(nil), c.List...) // make a copy
list[0].Text = m[2]
-
return m[1], (&ast.CommentGroup{List: list}).Text()
}
}
// collect MARKER(...): annotations
for _, c := range src.Comments {
if marker, text := readNote(c); marker != "" {
- // Remove r.bugs in a separate CL along with
- // any necessary changes to client code.
+ r.notes[marker] = append(r.notes[marker], text)
if marker == "BUG" {
r.bugs = append(r.bugs, text)
- } else {
- r.notes[marker] = append(r.notes[marker], text)
}
}
}
testdata/a0.go
testdata/a1.go
+BUGS .Bugs is now deprecated, please use .Notes instead
+ // bug0
+ // bug1
+
BUGS
// bug0
// bug1
-SECBUG
+SECBUGS
// sec hole 0 need to fix asap
-TODO
+TODOS
// todo0
// todo1
testdata/a0.go
testdata/a1.go
+BUGS .Bugs is now deprecated, please use .Notes instead
+ // bug0
+ // bug1
+
BUGS
// bug0
// bug1
-SECBUG
+SECBUGS
// sec hole 0 need to fix asap
-TODO
+TODOS
// todo0
// todo1
testdata/a0.go
testdata/a1.go
+BUGS .Bugs is now deprecated, please use .Notes instead
+ // bug0
+ // bug1
+
BUGS
// bug0
// bug1
-SECBUG
+SECBUGS
// sec hole 0 need to fix asap
-TODO
+TODOS
// todo0
// todo1
//TODO(uid): todo0
+// A note with some spaces after it, should be ignored (watch out for
+// emacs modes that remove trailing whitespace).
+//NOTE(uid):
+
// SECBUG(uid): sec hole 0
// need to fix asap
{{end}}{{end}}{{end}}{{/*
*/}}{{with .Bugs}}
-BUGS
+BUGS .Bugs is now deprecated, please use .Notes instead
{{range .}} {{synopsis .}}
{{end}}{{end}}{{with .Notes}}{{range $marker, $content := .}}
-{{$marker}}
+{{$marker}}S
{{range $content}} {{synopsis .}}
{{end}}{{end}}{{end}}
\ No newline at end of file