github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/lib/godoc/package.html (about) 1 <!-- 2 Copyright 2009 The Go Authors. All rights reserved. 3 Use of this source code is governed by a BSD-style 4 license that can be found in the LICENSE file. 5 --> 6 <!-- 7 Note: Static (i.e., not template-generated) href and id 8 attributes start with "pkg-" to make it impossible for 9 them to conflict with generated attributes (some of which 10 correspond to Go identifiers). 11 --> 12 {{with .PDoc}} 13 {{if $.IsMain}} 14 {{/* command documentation */}} 15 {{comment_html .Doc}} 16 {{else}} 17 {{/* package documentation */}} 18 <div id="short-nav"> 19 <dl> 20 <dd><code>import "{{html .ImportPath}}"</code></dd> 21 </dl> 22 <dl> 23 <dd><a href="#pkg-overview" class="overviewLink">Overview</a></dd> 24 <dd><a href="#pkg-index" class="indexLink">Index</a></dd> 25 {{if $.Examples}} 26 <dd><a href="#pkg-examples" class="examplesLink">Examples</a></dd> 27 {{end}} 28 {{if $.Dirs}} 29 <dd><a href="#pkg-subdirectories">Subdirectories</a></dd> 30 {{end}} 31 </dl> 32 </div> 33 <!-- The package's Name is printed as title by the top-level template --> 34 <div id="pkg-overview" class="toggleVisible"> 35 <div class="collapsed"> 36 <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2> 37 </div> 38 <div class="expanded"> 39 <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2> 40 {{comment_html .Doc}} 41 </div> 42 </div> 43 {{example_html $ ""}} 44 45 <div id="pkg-index" class="toggleVisible"> 46 <div class="collapsed"> 47 <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2> 48 </div> 49 <div class="expanded"> 50 <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2> 51 52 <!-- Table of contents for API; must be named manual-nav to turn off auto nav. --> 53 <div id="manual-nav"> 54 <dl> 55 {{if .Consts}} 56 <dd><a href="#pkg-constants">Constants</a></dd> 57 {{end}} 58 {{if .Vars}} 59 <dd><a href="#pkg-variables">Variables</a></dd> 60 {{end}} 61 {{range .Funcs}} 62 {{$name_html := html .Name}} 63 <dd><a href="#{{$name_html}}">{{node_html $ .Decl false}}</a></dd> 64 {{end}} 65 {{range .Types}} 66 {{$tname_html := html .Name}} 67 <dd><a href="#{{$tname_html}}">type {{$tname_html}}</a></dd> 68 {{range .Funcs}} 69 {{$name_html := html .Name}} 70 <dd> <a href="#{{$name_html}}">{{node_html $ .Decl false}}</a></dd> 71 {{end}} 72 {{range .Methods}} 73 {{$name_html := html .Name}} 74 <dd> <a href="#{{$tname_html}}.{{$name_html}}">{{node_html $ .Decl false}}</a></dd> 75 {{end}} 76 {{end}} 77 {{if $.Notes}} 78 {{range $marker, $item := $.Notes}} 79 <dd><a href="#pkg-note-{{$marker}}">{{noteTitle $marker | html}}s</a></dd> 80 {{end}} 81 {{end}} 82 </dl> 83 </div><!-- #manual-nav --> 84 85 {{if $.Examples}} 86 <div id="pkg-examples"> 87 <h4>Examples</h4> 88 <dl> 89 {{range $.Examples}} 90 <dd><a class="exampleLink" href="#example_{{.Name}}">{{example_name .Name}}</a></dd> 91 {{end}} 92 </dl> 93 </div> 94 {{end}} 95 96 {{with .Filenames}} 97 <h4>Package files</h4> 98 <p> 99 <span style="font-size:90%"> 100 {{range .}} 101 <a href="{{.|srcLink|html}}">{{.|filename|html}}</a> 102 {{end}} 103 </span> 104 </p> 105 {{end}} 106 </div><!-- .expanded --> 107 </div><!-- #pkg-index --> 108 109 {{with .Consts}} 110 <h2 id="pkg-constants">Constants</h2> 111 {{range .}} 112 <pre>{{node_html $ .Decl true}}</pre> 113 {{comment_html .Doc}} 114 {{end}} 115 {{end}} 116 {{with .Vars}} 117 <h2 id="pkg-variables">Variables</h2> 118 {{range .}} 119 <pre>{{node_html $ .Decl true}}</pre> 120 {{comment_html .Doc}} 121 {{end}} 122 {{end}} 123 {{range .Funcs}} 124 {{/* Name is a string - no need for FSet */}} 125 {{$name_html := html .Name}} 126 <h2 id="{{$name_html}}">func <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a></h2> 127 <pre>{{node_html $ .Decl true}}</pre> 128 {{comment_html .Doc}} 129 {{example_html $ .Name}} 130 {{end}} 131 {{range .Types}} 132 {{$tname := .Name}} 133 {{$tname_html := html .Name}} 134 <h2 id="{{$tname_html}}">type <a href="{{posLink_url $ .Decl}}">{{$tname_html}}</a></h2> 135 <pre>{{node_html $ .Decl true}}</pre> 136 {{comment_html .Doc}} 137 138 {{range .Consts}} 139 <pre>{{node_html $ .Decl true}}</pre> 140 {{comment_html .Doc}} 141 {{end}} 142 143 {{range .Vars}} 144 <pre>{{node_html $ .Decl true}}</pre> 145 {{comment_html .Doc}} 146 {{end}} 147 148 {{example_html $ $tname}} 149 150 {{range .Funcs}} 151 {{$name_html := html .Name}} 152 <h3 id="{{$name_html}}">func <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a></h3> 153 <pre>{{node_html $ .Decl true}}</pre> 154 {{comment_html .Doc}} 155 {{example_html $ .Name}} 156 {{end}} 157 158 {{range .Methods}} 159 {{$name_html := html .Name}} 160 <h3 id="{{$tname_html}}.{{$name_html}}">func ({{html .Recv}}) <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a></h3> 161 <pre>{{node_html $ .Decl true}}</pre> 162 {{comment_html .Doc}} 163 {{$name := printf "%s_%s" $tname .Name}} 164 {{example_html $ $name}} 165 {{end}} 166 {{end}} 167 {{end}} 168 169 {{with $.Notes}} 170 {{range $marker, $content := .}} 171 <h2 id="pkg-note-{{$marker}}">{{noteTitle $marker | html}}s</h2> 172 <ul style="list-style: none; padding: 0;"> 173 {{range .}} 174 <li><a href="{{posLink_url $ .}}">☞</a> {{html .Body}}</li> 175 {{end}} 176 </ul> 177 {{end}} 178 {{end}} 179 {{end}} 180 181 {{with .PAst}} 182 <pre>{{node_html $ . false}}</pre> 183 {{end}} 184 185 {{with .Dirs}} 186 {{/* DirList entries are numbers and strings - no need for FSet */}} 187 {{if $.PDoc}} 188 <h2 id="pkg-subdirectories">Subdirectories</h2> 189 {{else}} 190 <div class="pkgGopher"> 191 <img class="gopher" src="/doc/gopher/pkg.png"/> 192 </div> 193 {{end}} 194 <table class="dir"> 195 <tr> 196 <th>Name</th> 197 <th> </th> 198 <th style="text-align: left; width: auto">Synopsis</th> 199 </tr> 200 {{if not $.DirFlat}} 201 <tr> 202 <td><a href="..">..</a></td> 203 </tr> 204 {{end}} 205 {{range .List}} 206 {{if $.DirFlat}} 207 {{if .HasPkg}} 208 <tr> 209 <td class="name"><a href="{{html .Path}}/">{{html .Path}}</a></td> 210 <td> </td> 211 <td style="width: auto">{{html .Synopsis}}</td> 212 </tr> 213 {{end}} 214 {{else}} 215 <tr> 216 <td class="name">{{repeat ` ` .Depth}}<a href="{{html .Path}}/">{{html .Name}}</a></td> 217 <td> </td> 218 <td style="width: auto">{{html .Synopsis}}</td> 219 </tr> 220 {{end}} 221 {{end}} 222 </table> 223 {{if $.PDoc}}{{else}} 224 <p>Need more packages? Take a look at the <a href="http://code.google.com/p/go-wiki/wiki/Projects">Go Projects wiki page</a>.</p> 225 {{end}} 226 {{end}} 227 228 {{if $.Examples}} 229 <script> 230 $(document).ready(function() { 231 'use strict'; 232 // Set up playground when each element is toggled. 233 $('div.play').each(function (i, el) { 234 var built = false; 235 $(el).closest('.toggle').click(function() { 236 // Only set up playground once. 237 if (built) { 238 return; 239 } 240 built = true; 241 242 // Set up playground. 243 var code = $('.code', el); 244 playground({ 245 'codeEl': code, 246 'outputEl': $('.output', el), 247 'runEl': $('.run', el), 248 'fmtEl': $('.fmt', el), 249 'shareEl': $('.share', el), 250 'shareRedirect': 'http://play.golang.org/p/' 251 }); 252 253 // Make the code textarea resize to fit content. 254 var resize = function() { 255 code.height(0); 256 var h = code[0].scrollHeight; 257 code.height(h+20); // minimize bouncing. 258 code.closest('.input').height(h); 259 }; 260 code.on('keydown', resize); 261 code.on('keyup', resize); 262 code.keyup(); // resize now. 263 }); 264 }); 265 }); 266 </script> 267 {{end}}