From a829d47117efb998a07c14b4a06857f6d5e216e3 Mon Sep 17 00:00:00 2001 From: Luigi Riefolo Date: Thu, 17 Nov 2016 03:10:15 +0100 Subject: [PATCH] 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 --- godoc/static/package.html | 16 ++++++++-------- godoc/static/static.go | 18 +++++++++--------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/godoc/static/package.html b/godoc/static/package.html index bf9cd1fe..067cfc2a 100644 --- a/godoc/static/package.html +++ b/godoc/static/package.html @@ -151,15 +151,15 @@ {{with .Consts}}

Constants

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

Variables

{{range .}} -
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{end}} {{end}} {{range .Funcs}} @@ -168,8 +168,8 @@

func {{$name_html}}

-
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{example_html $ .Name}} {{callgraph_html $ "" .Name}} @@ -180,17 +180,17 @@

type {{$tname_html}}

-
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{range .Consts}} -
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{end}} {{range .Vars}} -
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{end}} {{example_html $ $tname}} @@ -202,8 +202,8 @@

func {{$name_html}}

-
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{example_html $ .Name}} {{callgraph_html $ "" .Name}} {{end}} @@ -213,8 +213,8 @@

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

-
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{$name := printf "%s_%s" $tname .Name}} {{example_html $ $name}} {{callgraph_html $ .Recv .Name}} diff --git a/godoc/static/static.go b/godoc/static/static.go index 923270a1..f6e267e6 100644 --- a/godoc/static/static.go +++ b/godoc/static/static.go @@ -1599,8 +1599,8 @@ function cgAddChild(tree, ul, cgn) { {{if $.IsMain}} - {{/* command documentation */}} {{comment_html .Doc}} + {{/* command documentation */}} {{else}} {{/* package documentation */}}
@@ -1734,15 +1734,15 @@ function cgAddChild(tree, ul, cgn) { {{with .Consts}}

Constants

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

Variables

{{range .}} -
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{end}} {{end}} {{range .Funcs}} @@ -1751,8 +1751,8 @@ function cgAddChild(tree, ul, cgn) {

func {{$name_html}}

-
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{example_html $ .Name}} {{callgraph_html $ "" .Name}} @@ -1763,17 +1763,17 @@ function cgAddChild(tree, ul, cgn) {

type {{$tname_html}}

-
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{range .Consts}} -
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{end}} {{range .Vars}} -
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{end}} {{example_html $ $tname}} @@ -1785,8 +1785,8 @@ function cgAddChild(tree, ul, cgn) {

func {{$name_html}}

-
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{example_html $ .Name}} {{callgraph_html $ "" .Name}} {{end}} @@ -1796,8 +1796,8 @@ function cgAddChild(tree, ul, cgn) {

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

-
{{node_html $ .Decl true}}
{{comment_html .Doc}} +
{{node_html $ .Decl true}}
{{$name := printf "%s_%s" $tname .Name}} {{example_html $ $name}} {{callgraph_html $ .Recv .Name}}