| <!-- |
| Copyright 2009 The Go Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style |
| license that can be found in the LICENSE file. |
| --> |
| <!-- |
| Note: Static (i.e., not template-generated) href and id |
| attributes start with "pkg-" to make it impossible for |
| them to conflict with generated attributes (some of which |
| correspond to Go identifiers). |
| --> |
| {{define "layout"}} |
| |
| <article class="Pkg Article"> |
| |
| <h1>{{.title}}</h1> |
| |
| {{$canShare := not googleCN}} |
| {{$pkg := .pkg}} |
| {{with $pkg.PDoc}} |
| {{if $pkg.IsMain}} |
| {{/* command documentation */}} |
| {{$pkg.Comment .Doc}} |
| {{else}} |
| {{/* package documentation */}} |
| <div id="short-nav"> |
| <dl> |
| <dd><code>import "{{.ImportPath}}"</code></dd> |
| </dl> |
| <dl> |
| <dd><a href="#pkg-overview" class="overviewLink">Overview</a></dd> |
| <dd><a href="#pkg-index" class="indexLink">Index</a></dd> |
| {{if $pkg.Examples}} |
| <dd><a href="#pkg-examples" class="examplesLink">Examples</a></dd> |
| {{end}} |
| {{if $pkg.Dirs}} |
| <dd><a href="#pkg-subdirectories">Subdirectories</a></dd> |
| {{end}} |
| </dl> |
| </div> |
| <!-- The package's Name is printed as title by the top-level template --> |
| <div id="pkg-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> |
| {{$pkg.Comment .Doc}} |
| {{range $pkg.FmtExamples ""}}{{example . $canShare}}{{end}} |
| </div> |
| </div> |
| |
| <div id="pkg-index" class="toggleVisible"> |
| <div class="collapsed"> |
| <h2 class="toggleButton" title="Click to show Index section">Index ▸</h2> |
| </div> |
| <div class="expanded"> |
| <h2 class="toggleButton" title="Click to hide Index section">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="#pkg-constants">Constants</a></dd> |
| {{end}} |
| {{if .Vars}} |
| <dd><a href="#pkg-variables">Variables</a></dd> |
| {{end}} |
| {{range .Funcs}} |
| <dd><a href="#{{.Name}}">{{$pkg.NodeTOC .Decl}}</a></dd> |
| {{end}} |
| {{range .Types}} |
| {{$typeName := .Name}} |
| <dd><a href="#{{.Name}}">type {{.Name}}</a></dd> |
| {{range .Funcs}} |
| <dd> <a href="#{{.Name}}">{{$pkg.NodeTOC .Decl}}</a></dd> |
| {{end}} |
| {{range .Methods}} |
| <dd> <a href="#{{$typeName}}.{{.Name}}">{{$pkg.NodeTOC .Decl}}</a></dd> |
| {{end}} |
| {{end}} |
| {{if $pkg.Bugs}} |
| <dd><a href="#pkg-note-BUG">Bugs</a></dd> |
| {{end}} |
| </dl> |
| </div><!-- #manual-nav --> |
| |
| {{if $pkg.Examples}} |
| <div id="pkg-examples"> |
| <h3>Examples |
| <span class="js-expandAll expandAll collapsed">(Expand All)</span> |
| </h3> |
| <dl> |
| {{range $pkg.Examples}} |
| <dd><a class="exampleLink" href="#example_{{.Name}}">{{$pkg.ExampleName .Name}}</a></dd> |
| {{end}} |
| </dl> |
| </div> |
| {{end}} |
| |
| {{with .Filenames}} |
| <h3>Package files</h3> |
| <p> |
| <span style="font-size:90%"> |
| {{range .}} |
| <a href="/{{.}}">{{path.Base .}}</a> |
| {{end}} |
| </span> |
| </p> |
| {{end}} |
| </div><!-- .expanded --> |
| </div><!-- #pkg-index --> |
| |
| {{with .Consts}} |
| <h2 id="pkg-constants">Constants</h2> |
| {{range .}} |
| {{$pkg.Comment .Doc}} |
| <pre>{{$pkg.Node .Decl}}</pre> |
| {{end}} |
| {{end}} |
| {{with .Vars}} |
| <h2 id="pkg-variables">Variables</h2> |
| {{range .}} |
| {{$pkg.Comment .Doc}} |
| <pre>{{$pkg.Node .Decl}}</pre> |
| {{end}} |
| {{end}} |
| {{range .Funcs}} |
| {{/* Name is a string - no need for FSet */}} |
| <h2 id="{{.Name}}">func <a href="{{$pkg.SrcPosLink .Decl}}">{{.Name}}</a> |
| <a class="permalink" href="#{{.Name}}">¶</a> |
| {{$since := $pkg.Since "func" "" .Name}} |
| {{if $since}}<span title="Added in Go {{$since}}">{{$since}}</span>{{end}} |
| </h2> |
| <pre>{{$pkg.Node .Decl}}</pre> |
| {{$pkg.Comment .Doc}} |
| {{range $pkg.FmtExamples .Name}}{{example . $canShare}}{{end}} |
| {{end}} |
| {{range .Types}} |
| {{$typeName := .Name}} |
| <h2 id="{{.Name}}">type <a href="{{$pkg.SrcPosLink .Decl}}">{{$typeName}}</a> |
| <a class="permalink" href="#{{.Name}}">¶</a> |
| {{$since := $pkg.Since "type" "" .Name}} |
| {{if $since}}<span title="Added in Go {{$since}}">{{$since}}</span>{{end}} |
| </h2> |
| {{$pkg.Comment .Doc}} |
| <pre>{{$pkg.Node .Decl}}</pre> |
| |
| {{range .Consts}} |
| {{$pkg.Comment .Doc}} |
| <pre>{{$pkg.Node .Decl}}</pre> |
| {{end}} |
| |
| {{range .Vars}} |
| {{$pkg.Comment .Doc}} |
| <pre>{{$pkg.Node .Decl}}</pre> |
| {{end}} |
| |
| {{range $pkg.FmtExamples .Name}}{{example . $canShare}}{{end}} |
| |
| {{range .Funcs}} |
| <h3 id="{{.Name}}">func <a href="{{$pkg.SrcPosLink .Decl}}">{{.Name}}</a> |
| <a class="permalink" href="#{{.Name}}">¶</a> |
| {{$since := $pkg.Since "func" "" .Name}} |
| {{if $since}}<span title="Added in Go {{$since}}">{{$since}}</span>{{end}} |
| </h3> |
| <pre>{{$pkg.Node .Decl}}</pre> |
| {{$pkg.Comment .Doc}} |
| {{range $pkg.FmtExamples .Name}}{{example . $canShare}}{{end}} |
| {{end}} |
| |
| {{range .Methods}} |
| <h3 id="{{$typeName}}.{{.Name}}">func ({{html .Recv}}) <a href="{{$pkg.SrcPosLink .Decl}}">{{.Name}}</a> |
| <a class="permalink" href="#{{$typeName}}.{{.Name}}">¶</a> |
| {{$since := $pkg.Since "method" .Recv .Name}} |
| {{if $since}}<span title="Added in Go {{$since}}">{{$since}}</span>{{end}} |
| </h3> |
| <pre>{{$pkg.Node .Decl}}</pre> |
| {{$pkg.Comment .Doc}} |
| {{range $pkg.FmtExamples (printf "%s_%s" $typeName .Name)}}{{example . $canShare}}{{end}} |
| {{end}} |
| {{end}} |
| {{end}} |
| |
| {{with $pkg.Bugs}} |
| <h2 id="pkg-note-BUG">Bugs</h2> |
| <ul style="list-style: none; padding: 0;"> |
| {{range .}} |
| <li><a href="{{$pkg.SrcPosLink .}}" style="float: left;">☞</a> {{$pkg.Comment .Body}}</li> |
| {{end}} |
| </ul> |
| {{end}} |
| {{end}} |
| |
| {{with $pkg.Dirs}} |
| {{/* DirList entries are numbers and strings - no need for FSet */}} |
| {{if $pkg.PDoc}} |
| <h2 id="pkg-subdirectories">Subdirectories</h2> |
| {{end}} |
| <div class="pkg-dir"> |
| <table> |
| <tr> |
| <th class="pkg-name">Name</th> |
| <th class="pkg-synopsis">Synopsis</th> |
| </tr> |
| |
| {{if not (or (eq $pkg.Dirname "/src/cmd") $pkg.DirFlat)}} |
| <tr> |
| <td class="pkg-name"><a href="..">..</a></td> |
| <td class="pkg-synopsis"></td> |
| </tr> |
| {{end}} |
| |
| {{range .}} |
| <tr> |
| {{if $pkg.DirFlat}} |
| {{if .HasPkg}} |
| <td class="pkg-name"> |
| <a href="{{.Path}}/{{$pkg.ModeQuery}}">{{.Path}}</a> |
| </td> |
| {{end}} |
| {{else}} |
| <td class="pkg-name" style="padding-left: {{mul (sub .Depth 1) 20}}px;"> |
| <a href="{{.Path}}/{{$pkg.ModeQuery}}">{{.Name}}</a> |
| </td> |
| {{end}} |
| <td class="pkg-synopsis"> |
| {{.Synopsis}} |
| </td> |
| </tr> |
| {{end}} |
| </table> |
| </div> |
| {{end}} |
| |
| </article> |
| |
| {{end}} |
| |
| {{define "example ex canShare"}} |
| {{$canShare := .canShare}} |
| {{with .ex}} |
| <div id="example_{{.Name}}" class="toggle"> |
| <div class="collapsed"> |
| <p class="exampleHeading toggleButton">▸ <span class="text">Example{{.Page.ExampleSuffix .Name}}</span></p> |
| </div> |
| <div class="expanded"> |
| <p class="exampleHeading toggleButton">▾ <span class="text">Example{{.Page.ExampleSuffix .Name}}</span></p> |
| {{with .Doc}}<p>{{.}}</p>{{end}} |
| {{$output := .Output}} |
| {{with .Play}} |
| <div class="play"> |
| <div class="input"><textarea class="code" spellcheck="false">{{.}}</textarea></div> |
| <div class="output"><pre>{{html $output}}</pre></div> |
| <div class="buttons"> |
| <button class="Button Button--primary run" title="Run this code [shift-enter]">Run</button> |
| <button class="Button fmt" title="Format this code">Format</button> |
| {{if $canShare}} |
| <button class="Button share" title="Share this code">Share</button> |
| {{end}} |
| </div> |
| </div> |
| {{else}} |
| <p>Code:</p> |
| <pre class="code">{{.Code}}</pre> |
| {{with .Output}} |
| <p>Output:</p> |
| <pre class="output">{{.}}</pre> |
| {{end}} |
| {{end}} |
| </div> |
| </div> |
| {{end}} |
| {{end}} |