From 79682199ce56c9afa1edac6c61da3c7abb9393b7 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 2 Apr 2013 12:05:14 -0700 Subject: [PATCH] cmd/godoc: don't linkify index entries Fixes #5186. R=bradfitz CC=golang-dev https://golang.org/cl/8267044 --- lib/godoc/package.html | 24 ++++++++++++------------ src/cmd/godoc/godoc.go | 8 +++----- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/godoc/package.html b/lib/godoc/package.html index a7d47298a5d..aefbef9fd73 100644 --- a/lib/godoc/package.html +++ b/lib/godoc/package.html @@ -60,18 +60,18 @@ {{end}} {{range .Funcs}} {{$name_html := html .Name}} -
{{node_html $ .Decl}}
+
{{node_html $ .Decl false}}
{{end}} {{range .Types}} {{$tname_html := html .Name}}
type {{$tname_html}}
{{range .Funcs}} {{$name_html := html .Name}} -
    {{node_html $ .Decl}}
+
    {{node_html $ .Decl false}}
{{end}} {{range .Methods}} {{$name_html := html .Name}} -
    {{node_html $ .Decl}}
+
    {{node_html $ .Decl false}}
{{end}} {{end}} {{if $.Notes}} @@ -109,14 +109,14 @@ {{with .Consts}}

Constants

{{range .}} -
{{node_html $ .Decl}}
+
{{node_html $ .Decl true}}
{{comment_html .Doc}} {{end}} {{end}} {{with .Vars}}

Variables

{{range .}} -
{{node_html $ .Decl}}
+
{{node_html $ .Decl true}}
{{comment_html .Doc}} {{end}} {{end}} @@ -124,7 +124,7 @@ {{/* Name is a string - no need for FSet */}} {{$name_html := html .Name}}

func {{$name_html}}

-
{{node_html $ .Decl}}
+
{{node_html $ .Decl true}}
{{comment_html .Doc}} {{example_html $ .Name}} {{end}} @@ -132,16 +132,16 @@ {{$tname := .Name}} {{$tname_html := html .Name}}

type {{$tname_html}}

-
{{node_html $ .Decl}}
+
{{node_html $ .Decl true}}
{{comment_html .Doc}} {{range .Consts}} -
{{node_html $ .Decl}}
+
{{node_html $ .Decl true}}
{{comment_html .Doc}} {{end}} {{range .Vars}} -
{{node_html $ .Decl}}
+
{{node_html $ .Decl true}}
{{comment_html .Doc}} {{end}} @@ -150,7 +150,7 @@ {{range .Funcs}} {{$name_html := html .Name}}

func {{$name_html}}

-
{{node_html $ .Decl}}
+
{{node_html $ .Decl true}}
{{comment_html .Doc}} {{example_html $ .Name}} {{end}} @@ -158,7 +158,7 @@ {{range .Methods}} {{$name_html := html .Name}}

func ({{html .Recv}}) {{$name_html}}

-
{{node_html $ .Decl}}
+
{{node_html $ .Decl true}}
{{comment_html .Doc}} {{$name := printf "%s_%s" $tname .Name}} {{example_html $ $name}} @@ -179,7 +179,7 @@ {{end}} {{with .PAst}} -
{{node_html $ .}}
+
{{node_html $ . false}}
{{end}} {{with .Dirs}} diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go index 6f9e19d5f97..26b0b97e179 100644 --- a/src/cmd/godoc/godoc.go +++ b/src/cmd/godoc/godoc.go @@ -279,14 +279,12 @@ func nodeFunc(info *PageInfo, node interface{}) string { return buf.String() } -func node_htmlFunc(info *PageInfo, node interface{}) string { +func node_htmlFunc(info *PageInfo, node interface{}, linkify bool) string { var buf1 bytes.Buffer writeNode(&buf1, info.FSet, node) var buf2 bytes.Buffer - // Don't linkify full source text (info.PAst != nil) - identifier - // resolution is not strong enough without full type checking. - if n, _ := node.(ast.Node); n != nil && *declLinks && info.PAst == nil { + if n, _ := node.(ast.Node); n != nil && linkify && *declLinks { LinkifyText(&buf2, buf1.Bytes(), n) } else { FormatText(&buf2, buf1.Bytes(), -1, true, "", nil) @@ -394,7 +392,7 @@ func example_htmlFunc(info *PageInfo, funcName string) string { // print code cnode := &printer.CommentedNode{Node: eg.Code, Comments: eg.Comments} - code := node_htmlFunc(info, cnode) + code := node_htmlFunc(info, cnode, true) out := eg.Output wholeFile := true