Skip to content
This repository was archived by the owner on Jul 29, 2021. It is now read-only.

Commit b99566c

Browse files
authored
Merge pull request #8 from lordnynex/patch-1
Update Template
2 parents f8e22ea + a3dac2e commit b99566c

File tree

1 file changed

+45
-21
lines changed

1 file changed

+45
-21
lines changed

template.go

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,78 @@
11
package main
22

3-
var pkgTemplate = `{{with .PDoc}}{{if $.IsMain}}
4-
# {{ base .ImportPath }}
5-
3+
var pkgTemplate = `{{with .PDoc}}
4+
{{if $.IsMain}}
5+
> {{ base .ImportPath }}
66
{{comment_md .Doc}}
77
{{else}}
88
# {{ .Name }}
9-
import "{{.ImportPath}}"
9+
` + "`" + `import "{{.ImportPath}}"` + "`" + `
10+
11+
* [Overview](#pkg-overview)
12+
* [Index](#pkg-index){{if $.Examples}}
13+
* [Examples](#pkg-examples){{- end}}{{if $.Dirs}}
14+
* [Subdirectories](#pkg-subdirectories){{- end}}
1015
16+
## <a name="pkg-overview">Overview</a>
1117
{{comment_md .Doc}}
1218
{{example_html $ ""}}
1319
14-
{{with .Consts}}## Constants
15-
{{range .}}{{node $ .Decl | pre}}
20+
## <a name="pkg-index">Index</a>
21+
{{- if .Consts}}* [Constants](#pkg-constants){{end}}
22+
{{- if .Vars}}* [Variables](#pkg-variables){{end}}{{- range .Funcs -}}{{$name_html := html .Name}}
23+
* [{{node_html $ .Decl false | sanitize}}](#{{$name_html}}){{- end}}{{- range .Types}}{{$tname_html := html .Name}}
24+
* [type {{$tname_html}}](#{{$tname_html}}){{- range .Funcs}}{{$name_html := html .Name}}
25+
* [{{node_html $ .Decl false | sanitize}}](#{{$name_html}}){{- end}}{{- range .Methods}}{{$name_html := html .Name}}
26+
* [{{node_html $ .Decl false | sanitize}}](#{{$tname_html}}.{{$name_html}}){{- end}}{{- end}}{{- if $.Notes}}{{- range $marker, $item := $.Notes}}
27+
* [{{noteTitle $marker | html}}s](#pkg-note-{{$marker}}){{end}}{{end}}
28+
{{if $.Examples}}
29+
#### <a name="pkg-examples">Examples</a>{{- range $.Examples}}
30+
* [{{example_name .Name}}](#example_{{.Name}}){{- end}}{{- end}}
31+
{{with .Filenames}}
32+
#### <a name="pkg-files">Package files</a>
33+
{{range .}}[{{.|filename|html}}]({{.|srcLink|html}}) {{end}}
34+
{{end}}
35+
36+
{{with .Consts}}## <a name="pkg-constants">Constants</a>
37+
{{range .}}{{node $ .Decl true | pre}}
1638
{{comment_md .Doc}}{{end}}{{end}}
17-
{{with .Vars}}## Variables
39+
{{with .Vars}}## <a name="pkg-variables">Variables</a>
1840
{{range .}}{{node $ .Decl | pre}}
1941
{{comment_md .Doc}}{{end}}{{end}}
20-
{{range .Funcs}}{{$name_html := html .Name}}## func {{$name_html}}
42+
43+
{{range .Funcs}}{{$name_html := html .Name}}## <a name="{{$name_html}}">func</a> [{{$name_html}}]({{posLink_url $ .Decl}})
2144
{{node $ .Decl | pre}}
2245
{{comment_md .Doc}}
23-
{{example_html $ .Name}}{{end}}
24-
{{range .Types}}{{$tname := .Name}}{{$tname_html := html .Name}}## type {{$tname_html}}
46+
{{example_html $ .Name}}
47+
{{callgraph_html $ "" .Name}}{{end}}
48+
{{range .Types}}{{$tname := .Name}}{{$tname_html := html .Name}}## <a name="{{$tname_html}}">type</a> [{{$tname_html}}]({{posLink_url $ .Decl}})
2549
{{node $ .Decl | pre}}
26-
{{comment_md .Doc}}
27-
28-
{{range .Consts}}{{node $ .Decl | pre }}
29-
{{comment_md .Doc}}{{end}}
30-
31-
{{range .Vars}}{{node $ .Decl | pre }}
50+
{{comment_md .Doc}}{{range .Consts}}
51+
{{node $ .Decl | pre }}
52+
{{comment_md .Doc}}{{end}}{{range .Vars}}
53+
{{node $ .Decl | pre }}
3254
{{comment_md .Doc}}{{end}}
3355
3456
{{example_html $ $tname}}
57+
{{implements_html $ $tname}}
58+
{{methodset_html $ $tname}}
3559
36-
{{range .Funcs}}{{$name_html := html .Name}}### func {{$name_html}}
60+
{{range .Funcs}}{{$name_html := html .Name}}### <a name="{{$name_html}}">func</a> [{{$name_html}}]({{posLink_url $ .Decl}})
3761
{{node $ .Decl | pre}}
3862
{{comment_md .Doc}}
3963
{{example_html $ .Name}}{{end}}
64+
{{callgraph_html $ "" .Name}}
4065
41-
{{range .Methods}}{{$name_html := html .Name}}### func ({{md .Recv}}) {{$name_html}}
66+
{{range .Methods}}{{$name_html := html .Name}}### <a name="{{$tname_html}}.{{$name_html}}">func</a> ({{md .Recv}}) [{{$name_html}}]({{posLink_url $ .Decl}})
4267
{{node $ .Decl | pre}}
4368
{{comment_md .Doc}}
4469
{{$name := printf "%s_%s" $tname .Name}}{{example_html $ $name}}
70+
{{callgraph_html $ .Recv .Name}}
4571
{{end}}{{end}}{{end}}
4672
4773
{{with $.Notes}}
4874
{{range $marker, $content := .}}
49-
## {{noteTitle $marker | html}}s
75+
## <a name="pkg-note-{{$marker}}">{{noteTitle $marker | html}}s
5076
<ul style="list-style: none; padding: 0;">
5177
{{range .}}
5278
<li><a href="{{posLink_url $ .}}">&#x261e;</a> {{html .Body}}</li>
@@ -55,7 +81,5 @@ var pkgTemplate = `{{with .PDoc}}{{if $.IsMain}}
5581
{{end}}
5682
{{end}}
5783
{{end}}
58-
59-
{{with .PAst}}{{node_html $ . false}}{{end}}
6084
- - -
6185
Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)`

0 commit comments

Comments
 (0)