cmd/godoc: show comment before code block

The existing implementation shows a comment after its code block.
This causes confusion regarding how the comment relates to a code block.
Comments have been moved before their relative code blocks.

Fixes golang/go#16728

Change-Id: Ie07a6dd2f340a2555513662f263d26377060f93b
Reviewed-on: https://go-review.googlesource.com/33279
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Luigi Riefolo 2016-11-17 03:10:15 +01:00 committed by Alan Donovan
parent e64f1a4c63
commit a829d47117
2 changed files with 17 additions and 17 deletions

View File

@ -151,15 +151,15 @@
{{with .Consts}}
<h2 id="pkg-constants">Constants</h2>
{{range .}}
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{end}}
{{end}}
{{with .Vars}}
<h2 id="pkg-variables">Variables</h2>
{{range .}}
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{end}}
{{end}}
{{range .Funcs}}
@ -168,8 +168,8 @@
<h2 id="{{$name_html}}">func <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a>
<a class="permalink" href="#{{$name_html}}">&#xb6;</a>
</h2>
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{example_html $ .Name}}
{{callgraph_html $ "" .Name}}
@ -180,17 +180,17 @@
<h2 id="{{$tname_html}}">type <a href="{{posLink_url $ .Decl}}">{{$tname_html}}</a>
<a class="permalink" href="#{{$tname_html}}">&#xb6;</a>
</h2>
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{range .Consts}}
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{end}}
{{range .Vars}}
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{end}}
{{example_html $ $tname}}
@ -202,8 +202,8 @@
<h3 id="{{$name_html}}">func <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a>
<a class="permalink" href="#{{$name_html}}">&#xb6;</a>
</h3>
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{example_html $ .Name}}
{{callgraph_html $ "" .Name}}
{{end}}
@ -213,8 +213,8 @@
<h3 id="{{$tname_html}}.{{$name_html}}">func ({{html .Recv}}) <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a>
<a class="permalink" href="#{{$tname_html}}.{{$name_html}}">&#xb6;</a>
</h3>
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{$name := printf "%s_%s" $tname .Name}}
{{example_html $ $name}}
{{callgraph_html $ .Recv .Name}}

View File

@ -1599,8 +1599,8 @@ function cgAddChild(tree, ul, cgn) {
</script>
{{if $.IsMain}}
{{/* command documentation */}}
{{comment_html .Doc}}
{{/* command documentation */}}
{{else}}
{{/* package documentation */}}
<div id="short-nav">
@ -1734,15 +1734,15 @@ function cgAddChild(tree, ul, cgn) {
{{with .Consts}}
<h2 id="pkg-constants">Constants</h2>
{{range .}}
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{end}}
{{end}}
{{with .Vars}}
<h2 id="pkg-variables">Variables</h2>
{{range .}}
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{end}}
{{end}}
{{range .Funcs}}
@ -1751,8 +1751,8 @@ function cgAddChild(tree, ul, cgn) {
<h2 id="{{$name_html}}">func <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a>
<a class="permalink" href="#{{$name_html}}">&#xb6;</a>
</h2>
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{example_html $ .Name}}
{{callgraph_html $ "" .Name}}
@ -1763,17 +1763,17 @@ function cgAddChild(tree, ul, cgn) {
<h2 id="{{$tname_html}}">type <a href="{{posLink_url $ .Decl}}">{{$tname_html}}</a>
<a class="permalink" href="#{{$tname_html}}">&#xb6;</a>
</h2>
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{range .Consts}}
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{end}}
{{range .Vars}}
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{end}}
{{example_html $ $tname}}
@ -1785,8 +1785,8 @@ function cgAddChild(tree, ul, cgn) {
<h3 id="{{$name_html}}">func <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a>
<a class="permalink" href="#{{$name_html}}">&#xb6;</a>
</h3>
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{example_html $ .Name}}
{{callgraph_html $ "" .Name}}
{{end}}
@ -1796,8 +1796,8 @@ function cgAddChild(tree, ul, cgn) {
<h3 id="{{$tname_html}}.{{$name_html}}">func ({{html .Recv}}) <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a>
<a class="permalink" href="#{{$tname_html}}.{{$name_html}}">&#xb6;</a>
</h3>
<pre>{{node_html $ .Decl true}}</pre>
{{comment_html .Doc}}
<pre>{{node_html $ .Decl true}}</pre>
{{$name := printf "%s_%s" $tname .Name}}
{{example_html $ $name}}
{{callgraph_html $ .Recv .Name}}