mirror of
https://github.com/golang/go
synced 2024-11-18 16:14:46 -07:00
go.tools/cmd/godoc: copy templates from $GOROOT/lib/godoc
R=golang-dev, r CC=golang-dev https://golang.org/cl/12209043
This commit is contained in:
parent
ae07aa6055
commit
508186a765
@ -53,7 +53,10 @@ import (
|
||||
"code.google.com/p/go.tools/godoc/vfs/zipfs"
|
||||
)
|
||||
|
||||
const defaultAddr = ":6060" // default webserver address
|
||||
const (
|
||||
defaultAddr = ":6060" // default webserver address
|
||||
templatePath = "code.google.com/p/go.tools/cmd/godoc/template"
|
||||
)
|
||||
|
||||
var (
|
||||
// file system to serve
|
||||
@ -187,14 +190,19 @@ func main() {
|
||||
}
|
||||
|
||||
// Determine file system to use.
|
||||
// TODO(gri) - fs and fsHttp should really be the same. Try to unify.
|
||||
// - fsHttp doesn't need to be set up in command-line mode,
|
||||
// same is true for the http handlers in initHandlers.
|
||||
if *zipfile == "" {
|
||||
// use file system of underlying OS
|
||||
fs.Bind("/", vfs.OS(*goroot), "/", vfs.BindReplace)
|
||||
if *templateDir != "" {
|
||||
fs.Bind("/lib/godoc", vfs.OS(*templateDir), "/", vfs.BindBefore)
|
||||
} else {
|
||||
// Read templates from go.tools repository; if not
|
||||
// found there, fall back on $GOROOT/lib/godoc
|
||||
// which will be present in binary distributions.
|
||||
pkg, err := build.Import(templatePath, "", build.FindOnly)
|
||||
if err == nil {
|
||||
fs.Bind("/lib/godoc", vfs.OS(pkg.Dir), "/", vfs.BindReplace)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// use file system specified via .zip file (path separator must be '/')
|
||||
|
56
cmd/godoc/template/codewalk.html
Normal file
56
cmd/godoc/template/codewalk.html
Normal file
@ -0,0 +1,56 @@
|
||||
<!--
|
||||
Copyright 2010 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.
|
||||
-->
|
||||
|
||||
<style type='text/css'>@import "/doc/codewalk/codewalk.css";</style>
|
||||
<script type="text/javascript" src="/doc/codewalk/codewalk.js"></script>
|
||||
|
||||
<div id="codewalk-main">
|
||||
<div class="left" id="code-column">
|
||||
<div id='sizer'></div>
|
||||
<div id="code-area">
|
||||
<div id="code-header" align="center">
|
||||
<a id="code-popout-link" href="" target="_blank">
|
||||
<img title="View code in new window" alt="Pop Out Code" src="/doc/codewalk/popout.png" style="display: block; float: right;"/>
|
||||
</a>
|
||||
<select id="code-selector">
|
||||
{{range .File}}
|
||||
<option value="/doc/codewalk/?fileprint=/{{urlquery .}}">{{html .}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</div>
|
||||
<div id="code">
|
||||
<iframe class="code-display" name="code-display" id="code-display"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<div id="code-options" class="setting">
|
||||
<span>code on <a id="set-code-left" class="selected" href="#">left</a> • <a id="set-code-right" href="#">right</a></span>
|
||||
<span>code width <span id="code-column-width">70%</span></span>
|
||||
<span>filepaths <a id="show-filepaths" class="selected" href="#">shown</a> • <a id="hide-filepaths" href="#">hidden</a></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right" id="comment-column">
|
||||
<div id="comment-area">
|
||||
{{range .Step}}
|
||||
<div class="comment first last">
|
||||
<a class="comment-link" href="/doc/codewalk/?fileprint=/{{urlquery .File}}&lo={{urlquery .Lo}}&hi={{urlquery .Hi}}#mark" target="code-display"></a>
|
||||
<div class="comment-title">{{html .Title}}</div>
|
||||
<div class="comment-text">
|
||||
{{with .Err}}
|
||||
ERROR LOADING FILE: {{html .}}<br/><br/>
|
||||
{{end}}
|
||||
{{.XML}}
|
||||
</div>
|
||||
<div class="comment-text file-name"><span class="path-file">{{html .}}</span></div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<div id="comment-options" class="setting">
|
||||
<a id="prev-comment" href="#"><span class="hotkey">p</span>revious step</a>
|
||||
•
|
||||
<a id="next-comment" href="#"><span class="hotkey">n</span>ext step</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
16
cmd/godoc/template/codewalkdir.html
Normal file
16
cmd/godoc/template/codewalkdir.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!--
|
||||
Copyright 2010 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.
|
||||
-->
|
||||
|
||||
<table class="layout">
|
||||
{{range .}}
|
||||
<tr>
|
||||
{{$name_html := html .Name}}
|
||||
<td><a href="{{$name_html}}">{{$name_html}}</a></td>
|
||||
<td width="25"> </td>
|
||||
<td>{{html .Title}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
31
cmd/godoc/template/dirlist.html
Normal file
31
cmd/godoc/template/dirlist.html
Normal file
@ -0,0 +1,31 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<p>
|
||||
<table class="layout">
|
||||
<tr>
|
||||
<th align="left">File</th>
|
||||
<td width="25"> </td>
|
||||
<th align="right">Bytes</th>
|
||||
<td width="25"> </td>
|
||||
<th align="left">Modified</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="..">..</a></td>
|
||||
</tr>
|
||||
{{range .}}
|
||||
<tr>
|
||||
{{$name_html := fileInfoName . | html}}
|
||||
<td align="left"><a href="{{$name_html}}">{{$name_html}}</a></td>
|
||||
<td></td>
|
||||
<td align="right">{{html .Size}}</td>
|
||||
<td></td>
|
||||
<td align="left">{{fileInfoTime . | html}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
|
||||
</table>
|
||||
</p>
|
9
cmd/godoc/template/error.html
Normal file
9
cmd/godoc/template/error.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<p>
|
||||
<span class="alert" style="font-size:120%">{{html .}}</span>
|
||||
</p>
|
28
cmd/godoc/template/example.html
Normal file
28
cmd/godoc/template/example.html
Normal file
@ -0,0 +1,28 @@
|
||||
<div id="example_{{.Name}}" class="toggle">
|
||||
<div class="collapsed">
|
||||
<p class="exampleHeading toggleButton">▹ <span class="text">Example{{example_suffix .Name}}</span></p>
|
||||
</div>
|
||||
<div class="expanded">
|
||||
<p class="exampleHeading toggleButton">▾ <span class="text">Example{{example_suffix .Name}}</span></p>
|
||||
{{with .Doc}}<p>{{html .}}</p>{{end}}
|
||||
{{$output := .Output}}
|
||||
{{with .Play}}
|
||||
<div class="play">
|
||||
<div class="input"><textarea class="code">{{html .}}</textarea></div>
|
||||
<div class="output"><pre>{{html $output}}</pre></div>
|
||||
<div class="buttons">
|
||||
<a class="run" title="Run this code [shift-enter]">Run</a>
|
||||
<a class="fmt" title="Format this code">Format</a>
|
||||
<a class="share" title="Share this code">Share</a>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<p>Code:</p>
|
||||
<pre class="code">{{.Code}}</pre>
|
||||
{{with .Output}}
|
||||
<p>Output:</p>
|
||||
<pre class="output">{{html .}}</pre>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
94
cmd/godoc/template/godoc.html
Normal file
94
cmd/godoc/template/godoc.html
Normal file
@ -0,0 +1,94 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
{{with .Tabtitle}}
|
||||
<title>{{html .}} - The Go Programming Language</title>
|
||||
{{else}}
|
||||
<title>The Go Programming Language</title>
|
||||
{{end}}
|
||||
<link type="text/css" rel="stylesheet" href="/doc/style.css">
|
||||
{{if .SearchBox}}
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="godoc" href="/opensearch.xml" />
|
||||
{{end}}
|
||||
<script type="text/javascript">window.initFuncs = [];</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="topbar"{{if .Title}} class="wide"{{end}}><div class="container">
|
||||
|
||||
<form method="GET" action="/search">
|
||||
<div id="menu">
|
||||
<a href="/doc/">Documents</a>
|
||||
<a href="/ref/">References</a>
|
||||
<a href="/pkg/">Packages</a>
|
||||
<a href="/project/">The Project</a>
|
||||
<a href="/help/">Help</a>
|
||||
{{if .Playground}}
|
||||
<a id="playgroundButton" href="http://play.golang.org/" title="Show Go Playground">Play</a>
|
||||
{{end}}
|
||||
<input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
|
||||
</div>
|
||||
<div id="heading"><a href="/">The Go Programming Language</a></div>
|
||||
</form>
|
||||
|
||||
</div></div>
|
||||
|
||||
{{if .Playground}}
|
||||
<div id="playground" class="play">
|
||||
<div class="input"><textarea class="code">package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello, 世界")
|
||||
}</textarea></div>
|
||||
<div class="output"></div>
|
||||
<div class="buttons">
|
||||
<a class="run" title="Run this code [shift-enter]">Run</a>
|
||||
<a class="fmt" title="Format this code">Format</a>
|
||||
<a class="share" title="Share this code">Share</a>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div id="page"{{if .Title}} class="wide"{{end}}>
|
||||
<div class="container">
|
||||
|
||||
{{with .Title}}
|
||||
<div id="plusone"><g:plusone size="small" annotation="none"></g:plusone></div>
|
||||
<h1>{{html .}}</h1>
|
||||
{{end}}
|
||||
{{with .Subtitle}}
|
||||
<h2>{{html .}}</h2>
|
||||
{{end}}
|
||||
|
||||
{{/* The Table of Contents is automatically inserted in this <div>.
|
||||
Do not delete this <div>. */}}
|
||||
<div id="nav"></div>
|
||||
|
||||
{{/* Body is HTML-escaped elsewhere */}}
|
||||
{{printf "%s" .Body}}
|
||||
|
||||
<div id="footer">
|
||||
Build version {{html .Version}}.<br>
|
||||
Except as <a href="http://code.google.com/policies.html#restrictions">noted</a>,
|
||||
the content of this page is licensed under the
|
||||
Creative Commons Attribution 3.0 License,
|
||||
and code is licensed under a <a href="/LICENSE">BSD license</a>.<br>
|
||||
<a href="/doc/tos.html">Terms of Service</a> |
|
||||
<a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
|
||||
</div>
|
||||
|
||||
</div><!-- .container -->
|
||||
</div><!-- #page -->
|
||||
|
||||
<script type="text/javascript" src="/doc/jquery.js"></script>
|
||||
{{if .Playground}}
|
||||
<script type="text/javascript" src="/doc/play/playground.js"></script>
|
||||
{{end}}
|
||||
<script type="text/javascript" src="/doc/godocs.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
11
cmd/godoc/template/opensearch.xml
Normal file
11
cmd/godoc/template/opensearch.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
|
||||
<ShortName>godoc</ShortName>
|
||||
<Description>The Go Programming Language</Description>
|
||||
<Tags>go golang</Tags>
|
||||
<Contact />
|
||||
<Url type="text/html" template="{{.BaseURL}}/search?q={searchTerms}" />
|
||||
<Image height="15" width="16" type="image/x-icon">/favicon.ico</Image>
|
||||
<OutputEncoding>UTF-8</OutputEncoding>
|
||||
<InputEncoding>UTF-8</InputEncoding>
|
||||
</OpenSearchDescription>
|
226
cmd/godoc/template/package.html
Normal file
226
cmd/godoc/template/package.html
Normal file
@ -0,0 +1,226 @@
|
||||
<!--
|
||||
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).
|
||||
-->
|
||||
{{with .PDoc}}
|
||||
{{if $.IsMain}}
|
||||
{{/* command documentation */}}
|
||||
{{comment_html .Doc}}
|
||||
{{else}}
|
||||
{{/* package documentation */}}
|
||||
<div id="short-nav">
|
||||
<dl>
|
||||
<dd><code>import "{{html .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 $.Examples}}
|
||||
<dd><a href="#pkg-examples" class="examplesLink">Examples</a></dd>
|
||||
{{end}}
|
||||
{{if $.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>
|
||||
{{comment_html .Doc}}
|
||||
</div>
|
||||
</div>
|
||||
{{example_html $ ""}}
|
||||
|
||||
<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}}
|
||||
{{$name_html := html .Name}}
|
||||
<dd><a href="#{{$name_html}}">{{node_html $ .Decl false}}</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> <a href="#{{$name_html}}">{{node_html $ .Decl false}}</a></dd>
|
||||
{{end}}
|
||||
{{range .Methods}}
|
||||
{{$name_html := html .Name}}
|
||||
<dd> <a href="#{{$tname_html}}.{{$name_html}}">{{node_html $ .Decl false}}</a></dd>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if $.Notes}}
|
||||
{{range $marker, $item := $.Notes}}
|
||||
<dd><a href="#pkg-note-{{$marker}}">{{noteTitle $marker | html}}s</a></dd>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</dl>
|
||||
</div><!-- #manual-nav -->
|
||||
|
||||
{{if $.Examples}}
|
||||
<div id="pkg-examples">
|
||||
<h4>Examples</h4>
|
||||
<dl>
|
||||
{{range $.Examples}}
|
||||
<dd><a class="exampleLink" href="#example_{{.Name}}">{{example_name .Name}}</a></dd>
|
||||
{{end}}
|
||||
</dl>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{with .Filenames}}
|
||||
<h4>Package files</h4>
|
||||
<p>
|
||||
<span style="font-size:90%">
|
||||
{{range .}}
|
||||
<a href="{{.|srcLink|html}}">{{.|filename|html}}</a>
|
||||
{{end}}
|
||||
</span>
|
||||
</p>
|
||||
{{end}}
|
||||
</div><!-- .expanded -->
|
||||
</div><!-- #pkg-index -->
|
||||
|
||||
{{with .Consts}}
|
||||
<h2 id="pkg-constants">Constants</h2>
|
||||
{{range .}}
|
||||
<pre>{{node_html $ .Decl true}}</pre>
|
||||
{{comment_html .Doc}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{with .Vars}}
|
||||
<h2 id="pkg-variables">Variables</h2>
|
||||
{{range .}}
|
||||
<pre>{{node_html $ .Decl true}}</pre>
|
||||
{{comment_html .Doc}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{range .Funcs}}
|
||||
{{/* Name is a string - no need for FSet */}}
|
||||
{{$name_html := html .Name}}
|
||||
<h2 id="{{$name_html}}">func <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a></h2>
|
||||
<pre>{{node_html $ .Decl true}}</pre>
|
||||
{{comment_html .Doc}}
|
||||
{{example_html $ .Name}}
|
||||
{{end}}
|
||||
{{range .Types}}
|
||||
{{$tname := .Name}}
|
||||
{{$tname_html := html .Name}}
|
||||
<h2 id="{{$tname_html}}">type <a href="{{posLink_url $ .Decl}}">{{$tname_html}}</a></h2>
|
||||
<pre>{{node_html $ .Decl true}}</pre>
|
||||
{{comment_html .Doc}}
|
||||
|
||||
{{range .Consts}}
|
||||
<pre>{{node_html $ .Decl true}}</pre>
|
||||
{{comment_html .Doc}}
|
||||
{{end}}
|
||||
|
||||
{{range .Vars}}
|
||||
<pre>{{node_html $ .Decl true}}</pre>
|
||||
{{comment_html .Doc}}
|
||||
{{end}}
|
||||
|
||||
{{example_html $ $tname}}
|
||||
|
||||
{{range .Funcs}}
|
||||
{{$name_html := html .Name}}
|
||||
<h3 id="{{$name_html}}">func <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a></h3>
|
||||
<pre>{{node_html $ .Decl true}}</pre>
|
||||
{{comment_html .Doc}}
|
||||
{{example_html $ .Name}}
|
||||
{{end}}
|
||||
|
||||
{{range .Methods}}
|
||||
{{$name_html := html .Name}}
|
||||
<h3 id="{{$tname_html}}.{{$name_html}}">func ({{html .Recv}}) <a href="{{posLink_url $ .Decl}}">{{$name_html}}</a></h3>
|
||||
<pre>{{node_html $ .Decl true}}</pre>
|
||||
{{comment_html .Doc}}
|
||||
{{$name := printf "%s_%s" $tname .Name}}
|
||||
{{example_html $ $name}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{with $.Notes}}
|
||||
{{range $marker, $content := .}}
|
||||
<h2 id="pkg-note-{{$marker}}">{{noteTitle $marker | html}}s</h2>
|
||||
<ul style="list-style: none; padding: 0;">
|
||||
{{range .}}
|
||||
<li><a href="{{posLink_url $ .}}">☞</a> {{html .Body}}</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{with .PAst}}
|
||||
<pre>{{node_html $ . false}}</pre>
|
||||
{{end}}
|
||||
|
||||
{{with .Dirs}}
|
||||
{{/* DirList entries are numbers and strings - no need for FSet */}}
|
||||
{{if $.PDoc}}
|
||||
<h2 id="pkg-subdirectories">Subdirectories</h2>
|
||||
{{else}}
|
||||
<div class="pkgGopher">
|
||||
<img class="gopher" src="/doc/gopher/pkg.png"/>
|
||||
</div>
|
||||
{{end}}
|
||||
<table class="dir">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th> </th>
|
||||
<th style="text-align: left; width: auto">Synopsis</th>
|
||||
</tr>
|
||||
{{if not $.DirFlat}}
|
||||
<tr>
|
||||
<td><a href="..">..</a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{range .List}}
|
||||
{{if $.DirFlat}}
|
||||
{{if .HasPkg}}
|
||||
<tr>
|
||||
<td class="name"><a href="{{html .Path}}/">{{html .Path}}</a></td>
|
||||
<td> </td>
|
||||
<td style="width: auto">{{html .Synopsis}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{else}}
|
||||
<tr>
|
||||
<td class="name">{{repeat ` ` .Depth}}<a href="{{html .Path}}/">{{html .Name}}</a></td>
|
||||
<td> </td>
|
||||
<td style="width: auto">{{html .Synopsis}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</table>
|
||||
{{if $.PDoc}}{{else}}
|
||||
<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>
|
||||
{{end}}
|
||||
{{end}}
|
80
cmd/godoc/template/package.txt
Normal file
80
cmd/godoc/template/package.txt
Normal file
@ -0,0 +1,80 @@
|
||||
{{with .PAst}}{{node $ .}}{{end}}{{/*
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*/}}{{with .PDoc}}{{if $.IsMain}}COMMAND DOCUMENTATION
|
||||
|
||||
{{comment_text .Doc " " "\t"}}
|
||||
{{else}}PACKAGE DOCUMENTATION
|
||||
|
||||
package {{.Name}}
|
||||
import "{{.ImportPath}}"
|
||||
|
||||
{{comment_text .Doc " " "\t"}}
|
||||
{{example_text $ "" " "}}{{/*
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*/}}{{with .Consts}}
|
||||
CONSTANTS
|
||||
|
||||
{{range .}}{{node $ .Decl}}
|
||||
{{comment_text .Doc " " "\t"}}
|
||||
{{end}}{{end}}{{/*
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*/}}{{with .Vars}}
|
||||
VARIABLES
|
||||
|
||||
{{range .}}{{node $ .Decl}}
|
||||
{{comment_text .Doc " " "\t"}}
|
||||
{{end}}{{end}}{{/*
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*/}}{{with .Funcs}}
|
||||
FUNCTIONS
|
||||
|
||||
{{range .}}{{node $ .Decl}}
|
||||
{{comment_text .Doc " " "\t"}}
|
||||
{{example_text $ .Name " "}}{{end}}{{end}}{{/*
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*/}}{{with .Types}}
|
||||
TYPES
|
||||
|
||||
{{range .}}{{$tname := .Name}}{{node $ .Decl}}
|
||||
{{comment_text .Doc " " "\t"}}
|
||||
{{range .Consts}}{{node $ .Decl}}
|
||||
{{comment_text .Doc " " "\t"}}
|
||||
{{end}}{{range .Vars}}{{node $ .Decl}}
|
||||
{{comment_text .Doc " " "\t"}}
|
||||
{{end}}{{example_text $ .Name " "}}
|
||||
{{range .Funcs}}{{node $ .Decl}}
|
||||
{{comment_text .Doc " " "\t"}}
|
||||
{{example_text $ .Name " "}}
|
||||
{{end}}{{range .Methods}}{{node $ .Decl}}
|
||||
{{comment_text .Doc " " "\t"}}
|
||||
{{$name := printf "%s_%s" $tname .Name}}{{example_text $ $name " "}}{{end}}
|
||||
{{end}}{{end}}{{end}}{{/*
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*/}}{{with $.Notes}}
|
||||
{{range $marker, $content := .}}
|
||||
{{$marker}}S
|
||||
|
||||
{{range $content}}{{comment_text .Body " " "\t"}}
|
||||
{{end}}{{end}}{{end}}{{end}}{{/*
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*/}}{{with .Dirs}}
|
||||
SUBDIRECTORIES
|
||||
{{if $.DirFlat}}{{range .List}}{{if .HasPkg}}
|
||||
{{.Path}}{{end}}{{end}}
|
||||
{{else}}{{range .List}}
|
||||
{{repeat `. ` .Depth}}{{.Name}}{{end}}
|
||||
{{end}}{{end}}
|
109
cmd/godoc/template/search.html
Normal file
109
cmd/godoc/template/search.html
Normal file
@ -0,0 +1,109 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
{{$query_url := urlquery .Query}}
|
||||
{{with .Alert}}
|
||||
<p>
|
||||
<span class="alert" style="font-size:120%">{{html .}}</span>
|
||||
</p>
|
||||
{{end}}
|
||||
{{with .Alt}}
|
||||
<p>
|
||||
<span class="alert" style="font-size:120%">Did you mean: </span>
|
||||
{{range .Alts}}
|
||||
<a href="search?q={{urlquery .}}" style="font-size:120%">{{html .}}</a>
|
||||
{{end}}
|
||||
</p>
|
||||
{{end}}
|
||||
{{with .Pak}}
|
||||
<h2 id="Packages">Package {{html $.Query}}</h2>
|
||||
<p>
|
||||
<table class="layout">
|
||||
{{range .}}
|
||||
{{$pkg_html := pkgLink .Pak.Path | html}}
|
||||
<tr><td><a href="/{{$pkg_html}}">{{$pkg_html}}</a></td></tr>
|
||||
{{end}}
|
||||
</table>
|
||||
</p>
|
||||
{{end}}
|
||||
{{with .Hit}}
|
||||
{{with .Decls}}
|
||||
<h2 id="Global">Package-level declarations</h2>
|
||||
{{range .}}
|
||||
{{$pkg_html := pkgLink .Pak.Path | html}}
|
||||
<h3 id="Global_{{$pkg_html}}">package <a href="/{{$pkg_html}}">{{html .Pak.Name}}</a></h3>
|
||||
{{range .Files}}
|
||||
{{$src_html := srcLink .File.Path | html}}
|
||||
{{range .Groups}}
|
||||
{{range .}}
|
||||
<a href="{{$src_html}}?h={{$query_url}}#L{{infoLine .}}">{{$src_html}}:{{infoLine .}}</a>
|
||||
{{infoSnippet_html .}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{with .Others}}
|
||||
<h2 id="Local">Local declarations and uses</h2>
|
||||
{{range .}}
|
||||
{{$pkg_html := pkgLink .Pak.Path | html}}
|
||||
<h3 id="Local_{{$pkg_html}}">package <a href="/{{$pkg_html}}">{{html .Pak.Name}}</a></h3>
|
||||
{{range .Files}}
|
||||
{{$src_html := srcLink .File.Path | html}}
|
||||
<a href="{{$src_html}}?h={{$query_url}}">{{$src_html}}</a>
|
||||
<table class="layout">
|
||||
{{range .Groups}}
|
||||
<tr>
|
||||
<td width="25"></td>
|
||||
<th align="left" valign="top">{{index . 0 | infoKind_html}}</th>
|
||||
<td align="left" width="4"></td>
|
||||
<td>
|
||||
{{range .}}
|
||||
<a href="{{$src_html}}?h={{$query_url}}#L{{infoLine .}}">{{infoLine .}}</a>
|
||||
{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{with .Textual}}
|
||||
{{if $.Complete}}
|
||||
<h2 id="Textual">{{html $.Found}} textual occurrences</h2>
|
||||
{{else}}
|
||||
<h2 id="Textual">More than {{html $.Found}} textual occurrences</h2>
|
||||
<p>
|
||||
<span class="alert" style="font-size:120%">Not all files or lines containing "{{html $.Query}}" are shown.</span>
|
||||
</p>
|
||||
{{end}}
|
||||
<p>
|
||||
<table class="layout">
|
||||
{{range .}}
|
||||
{{$src_html := srcLink .Filename | html}}
|
||||
<tr>
|
||||
<td align="left" valign="top">
|
||||
<a href="{{$src_html}}?h={{$query_url}}">{{$src_html}}</a>:
|
||||
</td>
|
||||
<td align="left" width="4"></td>
|
||||
<th align="left" valign="top">{{len .Lines}}</th>
|
||||
<td align="left" width="4"></td>
|
||||
<td align="left">
|
||||
{{range .Lines}}
|
||||
<a href="{{$src_html}}?h={{$query_url}}#L{{html .}}">{{html .}}</a>
|
||||
{{end}}
|
||||
{{if not $.Complete}}
|
||||
...
|
||||
{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{if not $.Complete}}
|
||||
<tr><td align="left">...</td></tr>
|
||||
{{end}}
|
||||
</table>
|
||||
</p>
|
||||
{{end}}
|
47
cmd/godoc/template/search.txt
Normal file
47
cmd/godoc/template/search.txt
Normal file
@ -0,0 +1,47 @@
|
||||
QUERY
|
||||
{{.Query}}
|
||||
|
||||
{{with .Alert}}{{.}}
|
||||
{{end}}{{/* .Alert */}}{{/*
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*/}}{{with .Alt}}DID YOU MEAN
|
||||
|
||||
{{range .Alts}} {{.}}
|
||||
{{end}}
|
||||
{{end}}{{/* .Alt */}}{{/*
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*/}}{{with .Pak}}PACKAGE {{$.Query}}
|
||||
|
||||
{{range .}} {{pkgLink .Pak.Path}}
|
||||
{{end}}
|
||||
{{end}}{{/* .Pak */}}{{/*
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*/}}{{with .Hit}}{{with .Decls}}PACKAGE-LEVEL DECLARATIONS
|
||||
|
||||
{{range .}}package {{.Pak.Name}}
|
||||
{{range $file := .Files}}{{range .Groups}}{{range .}} {{srcLink $file.File.Path}}:{{infoLine .}}{{end}}
|
||||
{{end}}{{end}}{{/* .Files */}}
|
||||
{{end}}{{end}}{{/* .Decls */}}{{/*
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*/}}{{with .Others}}LOCAL DECLARATIONS AND USES
|
||||
|
||||
{{range .}}package {{.Pak.Name}}
|
||||
{{range $file := .Files}}{{range .Groups}}{{range .}} {{srcLink $file.File.Path}}:{{infoLine .}}
|
||||
{{end}}{{end}}{{end}}{{/* .Files */}}
|
||||
{{end}}{{end}}{{/* .Others */}}{{end}}{{/* .Hit */}}{{/*
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*/}}{{if .Textual}}{{if .Complete}}{{.Found}} TEXTUAL OCCURRENCES{{else}}MORE THAN {{.Found}} TEXTUAL OCCURRENCES{{end}}
|
||||
|
||||
{{range .Textual}}{{len .Lines}} {{srcLink .Filename}}
|
||||
{{end}}{{if not .Complete}}... ...
|
||||
{{end}}{{end}}
|
Loading…
Reference in New Issue
Block a user