forked from gglachant/godoc2ghmd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.go
92 lines (79 loc) · 3.26 KB
/
template.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package main
var pkgTemplate = `{{with .PDoc}}
{{if $.IsMain}}
> {{ base .ImportPath }}
{{comment_md .Doc}}
{{else}}
# {{ .Name }}
` + "`" + `import "{{.ImportPath | import_as}}"` + "`" + `
* [Overview](#pkg-overview)
* [Imported Packages](#pkg-imports)
* [Index](#pkg-index){{if $.Examples}}
* [Examples](#pkg-examples){{- end}}
## <a name="pkg-overview">Overview</a>
{{pkgdoc_md .Doc}}
{{example_md $ "" "#### "}}
## <a name="pkg-imports">Imported Packages</a>
{{list_imports $ .Imports (.ImportPath|import_as)}}
## <a name="pkg-index">Index</a>{{if .Consts}}
* [Constants](#pkg-constants){{end}}{{if .Vars}}
* [Variables](#pkg-variables){{end}}{{- range .Funcs -}}{{$name_html := html .Name}}
* [{{node_html $ .Decl false | sanitize | md}}](#{{$name_html}}){{- end}}{{- range .Types}}{{$tname_html := html .Name}}
* [type {{$tname_html}}](#{{$tname_html}}){{- range .Funcs}}{{$name_html := html .Name}}
* [{{node_html $ .Decl false | sanitize | md}}](#{{$name_html}}){{- end}}{{- range .Methods}}{{$name_html := html .Name}}
* [{{node_html $ .Decl false | sanitize | md}}](#{{$tname_html}}.{{$name_html}}){{- end}}{{- end}}{{- if $.Notes}}{{- range $marker, $item := $.Notes}}
* [{{noteTitle $marker | html}}s](#pkg-note-{{$marker}}){{end}}{{end}}
{{if $.Examples}}
#### <a name="pkg-examples">Examples</a>{{- range $.Examples}}
* [{{example_name .Name}}](#example_{{.Name}}){{- end}}{{- end}}
{{with .Filenames}}
#### <a name="pkg-files">Package files</a>
{{range .}}[{{.|filename|html}}]({{print "./" (.|filename)}}) {{end}}
{{end}}
{{with .Consts}}## <a name="pkg-constants">Constants</a>
{{range .}}{{node $ .Decl | pre}}
{{comment_md .Doc}}{{end}}{{end}}
{{with .Vars}}## <a name="pkg-variables">Variables</a>
{{range .}}{{node $ .Decl | pre}}
{{comment_md .Doc}}{{end}}{{end}}
{{range .Funcs}}{{$name_html := html .Name}}## <a name="{{$name_html}}">func</a> [{{$name_html}}]({{gh_url $ .Decl}})
{{node $ .Decl | pre}}
{{comment_md .Doc}}
{{example_md $ .Name "#### "}}
{{callgraph_html $ "" .Name}}{{end}}
{{range .Types}}{{$tname := .Name}}{{$tname_html := html .Name}}## <a name="{{$tname_html}}">type</a> [{{$tname_html}}]({{gh_url $ .Decl}})
{{node $ .Decl | pre}}
{{comment_md .Doc}}{{range .Consts}}
{{node $ .Decl | pre }}
{{comment_md .Doc}}{{end}}{{range .Vars}}
{{node $ .Decl | pre }}
{{comment_md .Doc}}{{end}}
{{example_md $ $tname "#### "}}
{{implements_html $ $tname}}
{{methodset_html $ $tname}}
{{range .Funcs}}{{$name_html := html .Name}}### <a name="{{$name_html}}">func</a> [{{$name_html}}]({{gh_url $ .Decl}})
{{node $ .Decl | pre}}
{{comment_md .Doc}}
{{example_md $ .Name "#### "}}{{end}}
{{callgraph_html $ "" .Name}}
{{range .Methods}}{{$name_html := html .Name}}### <a name="{{$tname_html}}.{{$name_html}}">func</a> ({{md .Recv}}) [{{$name_html}}]({{gh_url $ .Decl}})
{{node $ .Decl | pre}}
{{comment_md .Doc}}
{{$name := printf "%s_%s" $tname .Name}}
{{example_md $ $name "#### "}}
{{callgraph_html $ .Recv .Name}}
{{end}}{{end}}{{end}}
{{with $.Notes}}
{{range $marker, $content := .}}
## <a name="pkg-note-{{$marker}}">{{noteTitle $marker | html}}s
<ul style="list-style: none; padding: 0;">
{{range .}}
<li><a href="{{gh_url $ .}}">☞</a> {{html .Body}}</li>
{{end}}
</ul>
{{end}}
{{end}}
{{end}}
- - -
Generated by [godoc2ghmd](https://github.com/gglachant/godoc2ghmd)
`