forked from davecheney/godoc2md
/
template.go
61 lines (50 loc) · 1.53 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
package main
var pkgTemplate = `{{with .PDoc}}{{if $.IsMain}}
# {{ base .ImportPath }}
{{comment_md .Doc}}
{{else}}
# {{ .Name }}
import "{{.ImportPath}}"
{{comment_md .Doc}}
{{example_html $ ""}}
{{with .Consts}}## Constants
{{range .}}{{node $ .Decl | pre}}
{{comment_md .Doc}}{{end}}{{end}}
{{with .Vars}}## Variables
{{range .}}{{node $ .Decl | pre}}
{{comment_md .Doc}}{{end}}{{end}}
{{range .Funcs}}{{$name_html := html .Name}}## func {{$name_html}}
{{node $ .Decl | pre}}
{{comment_md .Doc}}
{{example_html $ .Name}}{{end}}
{{range .Types}}{{$tname := .Name}}{{$tname_html := html .Name}}## type {{$tname_html}}
{{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_html $ $tname}}
{{range .Funcs}}{{$name_html := html .Name}}### func {{$name_html}}
{{node $ .Decl | pre}}
{{comment_md .Doc}}
{{example_html $ .Name}}{{end}}
{{range .Methods}}{{$name_html := html .Name}}### func ({{md .Recv}}) {{$name_html}}
{{node $ .Decl | pre}}
{{comment_md .Doc}}
{{$name := printf "%s_%s" $tname .Name}}{{example_html $ $name}}
{{end}}{{end}}{{end}}
{{with $.Notes}}
{{range $marker, $content := .}}
## {{noteTitle $marker | html}}s
<ul style="list-style: none; padding: 0;">
{{range .}}
<li><a href="{{posLink_url $ .}}">☞</a> {{html .Body}}</li>
{{end}}
</ul>
{{end}}
{{end}}
{{end}}
{{with .PAst}}{{node_html $ . false}}{{end}}
- - -
Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)`