summaryrefslogtreecommitdiff
path: root/lib/godoc/package.html
diff options
context:
space:
mode:
Diffstat (limited to 'lib/godoc/package.html')
-rw-r--r--lib/godoc/package.html212
1 files changed, 151 insertions, 61 deletions
diff --git a/lib/godoc/package.html b/lib/godoc/package.html
index 7a89d780c..41677a69d 100644
--- a/lib/godoc/package.html
+++ b/lib/godoc/package.html
@@ -3,85 +3,161 @@
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
-{{with .PAst}}
- <pre>{{node_html . $.FSet}}</pre>
-{{end}}
{{with .PDoc}}
- <!-- PackageName is printed as title by the top-level template -->
- {{if $.IsPkg}}
- <p><code>import "{{html .ImportPath}}"</code></p>
- {{end}}
- {{comment_html .Doc}}
{{if $.IsPkg}}
+ <div id="short-nav">
+ <dl>
+ <dd><code>import "{{html .ImportPath}}"</code></dd>
+ </dl>
+ <dl>
+ <dd><a href="#overview" class="overviewLink">Overview</a></dd>
+ <dd><a href="#index">Index</a></dd>
+ {{if $.Examples}}
+ <dd><a href="#examples">Examples</a></dd>
+ {{end}}
+ {{if $.Dirs}}
+ <dd><a href="#subdirectories">Subdirectories</a></dd>
+ {{end}}
+ </dl>
+ </div>
+ <!-- The package's Name is printed as title by the top-level template -->
+ <div id="overview" class="toggleVisible">
+ <div class="collapsed">
+ <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
+ </div>
+ <div class="expanded">
+ <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
+ {{comment_html .Doc}}
+ </div>
+ </div>
+ {{example_html "" $.Examples $.FSet}}
+
+ <h2 id="index">Index</h2>
+ <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
+ <div id="manual-nav">
+ <dl>
+ {{if .Consts}}
+ <dd><a href="#constants">Constants</a></dd>
+ {{end}}
+ {{if .Vars}}
+ <dd><a href="#variables">Variables</a></dd>
+ {{end}}
+ {{range .Funcs}}
+ {{$name_html := html .Name}}
+ <dd><a href="#{{$name_html}}">{{node_html .Decl $.FSet}}</a></dd>
+ {{end}}
+ {{range .Types}}
+ {{$tname_html := html .Name}}
+ <dd><a href="#{{$tname_html}}">type {{$tname_html}}</a></dd>
+ {{range .Funcs}}
+ {{$name_html := html .Name}}
+ <dd>&nbsp; &nbsp; <a href="#{{$name_html}}">{{node_html .Decl $.FSet}}</a></dd>
+ {{end}}
+ {{range .Methods}}
+ {{$name_html := html .Name}}
+ <dd>&nbsp; &nbsp; <a href="#{{$tname_html}}.{{$name_html}}">{{node_html .Decl $.FSet}}</a></dd>
+ {{end}}
+ {{end}}
+ {{if .Bugs}}
+ <dd><a href="#bugs">Bugs</a></dd>
+ {{end}}
+ </dl>
+
+ {{if $.Examples}}
+ <h4 id="examples">Examples</h4>
+ <dl>
+ {{range $.Examples}}
+ <dd><a class="exampleLink" href="#example_{{.Name}}">{{example_name .Name}}</a></dd>
+ {{end}}
+ </dl>
+ {{end}}
+
{{with .Filenames}}
- <p>
<h4>Package files</h4>
+ <p>
<span style="font-size:90%">
{{range .}}
- <a href="/{{.|srcLink}}">{{.|filename|html}}</a>
+ <a href="{{.|srcLink|html}}">{{.|filename|html}}</a>
{{end}}
</span>
</p>
{{end}}
- {{end}}
- {{with .Consts}}
- <h2 id="Constants">Constants</h2>
- {{range .}}
- {{comment_html .Doc}}
- <pre>{{node_html .Decl $.FSet}}</pre>
+
+ {{with .Consts}}
+ <h2 id="constants">Constants</h2>
+ {{range .}}
+ <pre>{{node_html .Decl $.FSet}}</pre>
+ {{comment_html .Doc}}
+ {{end}}
{{end}}
- {{end}}
- {{with .Vars}}
- <h2 id="Variables">Variables</h2>
- {{range .}}
- {{comment_html .Doc}}
- <pre>{{node_html .Decl $.FSet}}</pre>
+ {{with .Vars}}
+ <h2 id="variables">Variables</h2>
+ {{range .}}
+ <pre>{{node_html .Decl $.FSet}}</pre>
+ {{comment_html .Doc}}
+ {{end}}
{{end}}
- {{end}}
- {{with .Funcs}}
- {{range .}}
+ {{range .Funcs}}
{{/* Name is a string - no need for FSet */}}
{{$name_html := html .Name}}
- <h2 id="{{$name_html}}">func <a href="/{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h2>
- <p><code>{{node_html .Decl $.FSet}}</code></p>
+ <h2 id="{{$name_html}}">func <a href="{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h2>
+ <pre>{{node_html .Decl $.FSet}}</pre>
{{comment_html .Doc}}
+ {{example_html .Name $.Examples $.FSet}}
{{end}}
- {{end}}
- {{with .Types}}
- {{range .}}
- {{$tname_html := node_html .Type.Name $.FSet}}
- <h2 id="{{$tname_html}}">type <a href="/{{posLink_url .Decl $.FSet}}">{{$tname_html}}</a></h2>
+ {{range .Types}}
+ {{$tname := .Name}}
+ {{$tname_html := html .Name}}
+ <h2 id="{{$tname_html}}">type <a href="{{posLink_url .Decl $.FSet}}">{{$tname_html}}</a></h2>
+ <pre>{{node_html .Decl $.FSet}}</pre>
{{comment_html .Doc}}
- <p><pre>{{node_html .Decl $.FSet}}</pre></p>
+
{{range .Consts}}
- {{comment_html .Doc}}
<pre>{{node_html .Decl $.FSet}}</pre>
+ {{comment_html .Doc}}
{{end}}
+
{{range .Vars}}
- {{comment_html .Doc}}
<pre>{{node_html .Decl $.FSet}}</pre>
+ {{comment_html .Doc}}
{{end}}
- {{range .Factories}}
+
+ {{example_html $tname $.Examples $.FSet}}
+
+ {{range .Funcs}}
{{$name_html := html .Name}}
- <h3 id="{{$tname_html}}.{{$name_html}}">func <a href="/{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h3>
- <p><code>{{node_html .Decl $.FSet}}</code></p>
+ <h3 id="{{$name_html}}">func <a href="{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h3>
+ <pre>{{node_html .Decl $.FSet}}</pre>
{{comment_html .Doc}}
+ {{example_html .Name $.Examples $.FSet}}
{{end}}
+
{{range .Methods}}
{{$name_html := html .Name}}
- <h3 id="{{$tname_html}}.{{$name_html}}">func ({{node_html .Recv $.FSet}}) <a href="/{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h3>
- <p><code>{{node_html .Decl $.FSet}}</code></p>
+ <h3 id="{{$tname_html}}.{{$name_html}}">func ({{html .Recv}}) <a href="{{posLink_url .Decl $.FSet}}">{{$name_html}}</a></h3>
+ <pre>{{node_html .Decl $.FSet}}</pre>
{{comment_html .Doc}}
+ {{$name := printf "%s_%s" $tname .Name}}
+ {{example_html $name $.Examples $.FSet}}
{{end}}
{{end}}
+ </div>
+ {{else}} {{/* not a package; is a command */}}
+ {{comment_html .Doc}}
{{end}}
+
{{with .Bugs}}
- <h2 id="Bugs">Bugs</h2>
+ <h2 id="bugs">Bugs</h2>
{{range .}}
{{comment_html .}}
{{end}}
{{end}}
{{end}}
+
+{{with .PAst}}
+ <pre>{{node_html . $.FSet}}</pre>
+{{end}}
+
{{with .PList}}
<h2>Other packages</h2>
<p>
@@ -91,32 +167,46 @@
{{end}}
</p>
{{end}}
+
{{with .Dirs}}
- <p class="detail">
- Need more packages? The
- <a href="http://godashboard.appspot.com/package">Package Dashboard</a>
- provides a list of <a href="/cmd/goinstall/">goinstallable</a> packages.
- </p>
{{/* DirList entries are numbers and strings - no need for FSet */}}
- <h2 id="Subdirectories">Subdirectories</h2>
- <p>
- <table class="layout">
- <tr>
- <th align="left" colspan="{{html .MaxHeight}}">Name</th>
- <td width="25">&nbsp;</td>
- <th align="left">Synopsis</th>
- </tr>
+ {{if $.PDoc}}
+ <h2 id="subdirectories">Subdirectories</h2>
+ {{else}}
+ <div class="pkgGopher">
+ <img class="gopher" src="/doc/gopher/pkg.png"/>
+ </div>
+ {{end}}
+ <table class="dir">
<tr>
- <th align="left"><a href="..">..</a></th>
+ <th>Name</th>
+ <th>&nbsp;&nbsp;&nbsp;&nbsp;</th>
+ <th style="text-align: left; width: auto">Synopsis</th>
</tr>
- {{range .List}}
+ {{if not $.DirFlat}}
<tr>
- {{repeat `<td width="25"></td>` .Depth}}
- <td align="left" colspan="{{html .Height}}"><a href="{{html .Path}}">{{html .Name}}</a></td>
- <td></td>
- <td align="left">{{html .Synopsis}}</td>
+ <td><a href="..">..</a></td>
</tr>
{{end}}
+ {{range .List}}
+ {{if $.DirFlat}}
+ {{if .HasPkg}}
+ <tr>
+ <td><a href="{{html .Path}}">{{html .Path}}</a></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td style="width: auto">{{html .Synopsis}}</td>
+ </tr>
+ {{end}}
+ {{else}}
+ <tr>
+ <td>{{repeat `&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;` .Depth}}<a href="{{html .Path}}">{{html .Name}}</a></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td style="width: auto">{{html .Synopsis}}</td>
+ </tr>
+ {{end}}
+ {{end}}
</table>
- </p>
+ {{if $.PDoc}}{{else}}
+ <p>Need more packages? Take a look at the <a href="http://godashboard.appspot.com/">Go Project Dashboard</a>.</p>
+ {{end}}
{{end}}