Commit 79682199 authored by Robert Griesemer's avatar Robert Griesemer

cmd/godoc: don't linkify index entries

Fixes #5186.

R=bradfitz
CC=golang-dev
https://golang.org/cl/8267044
parent 3a012c02
...@@ -60,18 +60,18 @@ ...@@ -60,18 +60,18 @@
{{end}} {{end}}
{{range .Funcs}} {{range .Funcs}}
{{$name_html := html .Name}} {{$name_html := html .Name}}
<dd><a href="#{{$name_html}}">{{node_html $ .Decl}}</a></dd> <dd><a href="#{{$name_html}}">{{node_html $ .Decl false}}</a></dd>
{{end}} {{end}}
{{range .Types}} {{range .Types}}
{{$tname_html := html .Name}} {{$tname_html := html .Name}}
<dd><a href="#{{$tname_html}}">type {{$tname_html}}</a></dd> <dd><a href="#{{$tname_html}}">type {{$tname_html}}</a></dd>
{{range .Funcs}} {{range .Funcs}}
{{$name_html := html .Name}} {{$name_html := html .Name}}
<dd>&nbsp; &nbsp; <a href="#{{$name_html}}">{{node_html $ .Decl}}</a></dd> <dd>&nbsp; &nbsp; <a href="#{{$name_html}}">{{node_html $ .Decl false}}</a></dd>
{{end}} {{end}}
{{range .Methods}} {{range .Methods}}
{{$name_html := html .Name}} {{$name_html := html .Name}}
<dd>&nbsp; &nbsp; <a href="#{{$tname_html}}.{{$name_html}}">{{node_html $ .Decl}}</a></dd> <dd>&nbsp; &nbsp; <a href="#{{$tname_html}}.{{$name_html}}">{{node_html $ .Decl false}}</a></dd>
{{end}} {{end}}
{{end}} {{end}}
{{if $.Notes}} {{if $.Notes}}
...@@ -109,14 +109,14 @@ ...@@ -109,14 +109,14 @@
{{with .Consts}} {{with .Consts}}
<h2 id="pkg-constants">Constants</h2> <h2 id="pkg-constants">Constants</h2>
{{range .}} {{range .}}
<pre>{{node_html $ .Decl}}</pre> <pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}} {{comment_html .Doc}}
{{end}} {{end}}
{{end}} {{end}}
{{with .Vars}} {{with .Vars}}
<h2 id="pkg-variables">Variables</h2> <h2 id="pkg-variables">Variables</h2>
{{range .}} {{range .}}
<pre>{{node_html $ .Decl}}</pre> <pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}} {{comment_html .Doc}}
{{end}} {{end}}
{{end}} {{end}}
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
{{/* Name is a string - no need for FSet */}} {{/* Name is a string - no need for FSet */}}
{{$name_html := html .Name}} {{$name_html := html .Name}}
<h2 id="{{$name_html}}">func <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a></h2> <h2 id="{{$name_html}}">func <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a></h2>
<pre>{{node_html $ .Decl}}</pre> <pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}} {{comment_html .Doc}}
{{example_html $ .Name}} {{example_html $ .Name}}
{{end}} {{end}}
...@@ -132,16 +132,16 @@ ...@@ -132,16 +132,16 @@
{{$tname := .Name}} {{$tname := .Name}}
{{$tname_html := html .Name}} {{$tname_html := html .Name}}
<h2 id="{{$tname_html}}">type <a href="{{posLink_url $ .Decl}}">{{$tname_html}}</a></h2> <h2 id="{{$tname_html}}">type <a href="{{posLink_url $ .Decl}}">{{$tname_html}}</a></h2>
<pre>{{node_html $ .Decl}}</pre> <pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}} {{comment_html .Doc}}
{{range .Consts}} {{range .Consts}}
<pre>{{node_html $ .Decl}}</pre> <pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}} {{comment_html .Doc}}
{{end}} {{end}}
{{range .Vars}} {{range .Vars}}
<pre>{{node_html $ .Decl}}</pre> <pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}} {{comment_html .Doc}}
{{end}} {{end}}
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
{{range .Funcs}} {{range .Funcs}}
{{$name_html := html .Name}} {{$name_html := html .Name}}
<h3 id="{{$name_html}}">func <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a></h3> <h3 id="{{$name_html}}">func <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a></h3>
<pre>{{node_html $ .Decl}}</pre> <pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}} {{comment_html .Doc}}
{{example_html $ .Name}} {{example_html $ .Name}}
{{end}} {{end}}
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
{{range .Methods}} {{range .Methods}}
{{$name_html := html .Name}} {{$name_html := html .Name}}
<h3 id="{{$tname_html}}.{{$name_html}}">func ({{html .Recv}}) <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a></h3> <h3 id="{{$tname_html}}.{{$name_html}}">func ({{html .Recv}}) <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a></h3>
<pre>{{node_html $ .Decl}}</pre> <pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}} {{comment_html .Doc}}
{{$name := printf "%s_%s" $tname .Name}} {{$name := printf "%s_%s" $tname .Name}}
{{example_html $ $name}} {{example_html $ $name}}
...@@ -179,7 +179,7 @@ ...@@ -179,7 +179,7 @@
{{end}} {{end}}
{{with .PAst}} {{with .PAst}}
<pre>{{node_html $ .}}</pre> <pre>{{node_html $ . false}}</pre>
{{end}} {{end}}
{{with .Dirs}} {{with .Dirs}}
......
...@@ -279,14 +279,12 @@ func nodeFunc(info *PageInfo, node interface{}) string { ...@@ -279,14 +279,12 @@ func nodeFunc(info *PageInfo, node interface{}) string {
return buf.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 var buf1 bytes.Buffer
writeNode(&buf1, info.FSet, node) writeNode(&buf1, info.FSet, node)
var buf2 bytes.Buffer var buf2 bytes.Buffer
// Don't linkify full source text (info.PAst != nil) - identifier if n, _ := node.(ast.Node); n != nil && linkify && *declLinks {
// resolution is not strong enough without full type checking.
if n, _ := node.(ast.Node); n != nil && *declLinks && info.PAst == nil {
LinkifyText(&buf2, buf1.Bytes(), n) LinkifyText(&buf2, buf1.Bytes(), n)
} else { } else {
FormatText(&buf2, buf1.Bytes(), -1, true, "", nil) FormatText(&buf2, buf1.Bytes(), -1, true, "", nil)
...@@ -394,7 +392,7 @@ func example_htmlFunc(info *PageInfo, funcName string) string { ...@@ -394,7 +392,7 @@ func example_htmlFunc(info *PageInfo, funcName string) string {
// print code // print code
cnode := &printer.CommentedNode{Node: eg.Code, Comments: eg.Comments} cnode := &printer.CommentedNode{Node: eg.Code, Comments: eg.Comments}
code := node_htmlFunc(info, cnode) code := node_htmlFunc(info, cnode, true)
out := eg.Output out := eg.Output
wholeFile := true wholeFile := true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment