{{html .}}
{{end}} {{with .Subtitle}}{{html .}}
{{end}} {{/* The Table of Contents is automatically inserted in this" + html + "
\n" + "" + escapeHTML(data.Callee) + "
:\n"; for (var i = 0; i < data.Callers.length; i++) { var caller = data.Callers[i]; html += "
" + escapeHTML(caller.Func) + "
";
var sites = caller.Sites;
if (sites != null && sites.length > 0) {
html += " at line ";
for (var j = 0; j < sites.length; j++) {
if (j > 0) {
html += ", ";
}
html += "" + makeAnchor(sites[j]) + "
";
}
}
html += "\n"; } showLowFrame(html); }; // onClickCallees is the onclick action for the '(' token of a function call. document.onClickCallees = function(index) { var data = document.ANALYSIS_DATA[index] if (data.Callees.length == 1) { document.location = data.Callees[0].Href; // jump to sole callee return; } var html = "Callees of this " + escapeHTML(data.Descr) + ":
\n"; for (var i = 0; i < data.Callees.length; i++) { html += "
" + makeAnchor(data.Callees[i]) + "
\n"; } showLowFrame(html); }; // onClickTypeInfo is the onclick action for identifiers declaring a named type. document.onClickTypeInfo = function(index) { var data = document.ANALYSIS_DATA[index]; var html = "Type
" + data.Name + "
: " +
" (size=" + data.Size + ", align=" + data.Align + ")\n"; html += implementsHTML(data); html += methodsetHTML(data); showLowFrame(html); }; // implementsHTML returns HTML for the implements relation of the // specified TypeInfoJSON value. function implementsHTML(info) { var html = ""; if (info.ImplGroups != null) { for (var i = 0; i < info.ImplGroups.length; i++) { var group = info.ImplGroups[i]; var x = "
" + escapeHTML(group.Descr) + "
";
for (var j = 0; j < group.Facts.length; j++) {
var fact = group.Facts[j];
var y = "" + makeAnchor(fact.Other) + "
";
if (fact.ByKind != null) {
html += escapeHTML(fact.ByKind) + " type " + y + " implements " + x;
} else {
html += x + " implements " + y;
}
html += "\n"; } } } return html; } // methodsetHTML returns HTML for the methodset of the specified // TypeInfoJSON value. function methodsetHTML(info) { var html = ""; if (info.Methods != null) { for (var i = 0; i < info.Methods.length; i++) { html += "
" + makeAnchor(info.Methods[i]) + "
\n"; } } return html; } // onClickComm is the onclick action for channel "make" and "<-" // send/receive tokens. document.onClickComm = function(index) { var ops = document.ANALYSIS_DATA[index].Ops if (ops.length == 1) { document.location = ops[0].Op.Href; // jump to sole element return; } var html = "Operations on this channel:
\n"; for (var i = 0; i < ops.length; i++) { html += makeAnchor(ops[i].Op) + " by
" + escapeHTML(ops[i].Fn) + "
\n"; } if (ops.length == 0) { html += "(none)
\n"; } showLowFrame(html); }; $(window).load(function() { // Scroll window so that first selection is visible. // (This means we don't need to emit id='L%d' spans for each line.) // TODO(adonovan): ideally, scroll it so that it's under the pointer, // but I don't know how to get the pointer y coordinate. var elts = document.getElementsByClassName("selection"); if (elts.length > 0) { elts[0].scrollIntoView() } }); // setupTypeInfo populates the "Implements" and "Method set" toggle for // each type in the package doc. function setupTypeInfo() { for (var i in document.ANALYSIS_DATA) { var data = document.ANALYSIS_DATA[i]; var el = document.getElementById("implements-" + i); if (el != null) { // el != null => data is TypeInfoJSON. if (data.ImplGroups != null) { el.innerHTML = implementsHTML(data); el.parentNode.parentNode.style.display = "block"; } } var el = document.getElementById("methodset-" + i); if (el != null) { // el != null => data is TypeInfoJSON. if (data.Methods != null) { el.innerHTML = methodsetHTML(data); el.parentNode.parentNode.style.display = "block"; } } } } function setupCallgraphs() { if (document.CALLGRAPH == null) { return } var treeviews = document.getElementsByClassName("treeview"); for (var i in treeviews) { var tree = treeviews[i]; if (tree.id == null || tree.id.indexOf("callgraph-") != 0) { continue; } var id = tree.id.substring("callgraph-".length); $(tree).treeview({collapsed: true, animated: "fast"}); document.cgAddChildren(tree, tree, [id]); tree.parentNode.parentNode.style.display = "block"; } } document.cgAddChildren = function(tree, ul, indices) { if (indices != null) { for (var i = 0; i < indices.length; i++) { var li = cgAddChild(tree, ul, document.CALLGRAPH[indices[i]]); if (i == indices.length - 1) { $(li).addClass("last"); } } } $(tree).treeview({animated: "fast", add: ul}); } // cgAddChild adds an
- element ul. tree is the tree's root
- ☞ {{html .Body}} {{end}}
- element.
function cgAddChild(tree, ul, cgn) {
var li = document.createElement("li");
ul.appendChild(li);
li.className = "closed";
var code = document.createElement("code");
if (cgn.Callees != null) {
$(li).addClass("expandable");
// Event handlers and innerHTML updates don't play nicely together,
// hence all this explicit DOM manipulation.
var hitarea = document.createElement("div");
hitarea.className = "hitarea expandable-hitarea";
li.appendChild(hitarea);
li.appendChild(code);
var childUL = document.createElement("ul");
li.appendChild(childUL);
childUL.setAttribute('style', "display: none;");
var onClick = function() {
document.cgAddChildren(tree, childUL, cgn.Callees);
hitarea.removeEventListener('click', onClick)
};
hitarea.addEventListener('click', onClick);
} else {
li.appendChild(code);
}
code.innerHTML += " " + makeAnchor(cgn.Func);
return li
}
})();
`,
"jquery.js": `/*! jQuery v1.8.2 jquery.com | jquery.org/license */
(function(a,b){function G(a){var b=F[a]={};return p.each(a.split(s),function(a,c){b[c]=!0}),b}function J(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(I,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:+d+""===d?+d:H.test(d)?p.parseJSON(d):d}catch(f){}p.data(a,c,d)}else d=b}return d}function K(a){var b;for(b in a){if(b==="data"&&p.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function ba(){return!1}function bb(){return!0}function bh(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function bi(a,b){do a=a[b];while(a&&a.nodeType!==1);return a}function bj(a,b,c){b=b||0;if(p.isFunction(b))return p.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return p.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=p.grep(a,function(a){return a.nodeType===1});if(be.test(b))return p.filter(b,d,!c);b=p.filter(b,d)}return p.grep(a,function(a,d){return p.inArray(a,b)>=0===c})}function bk(a){var b=bl.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function bC(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function bD(a,b){if(b.nodeType!==1||!p.hasData(a))return;var c,d,e,f=p._data(a),g=p._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d
t |
Name | Synopsis | |
---|---|---|
.. | ||
{{html .Path}} | {{html .Synopsis}} | |
{{repeat ` + "`" + ` ` + "`" + ` .Depth}}{{html .Name}} | {{html .Synopsis}} |
Need more packages? Check out the sub-repositories and other Go projects.
{{end}} {{end}} `, "package.txt": `{{$info := .}}{{$filtered := .IsFiltered}}{{/* --------------------------------------- */}}{{if $filtered}}{{range .PAst}}{{range .Decls}}{{node $info .}}{{end}}{{end}}{{else}}{{with .PAst}}{{range $filename, $ast := .}}{{$filename}}: {{node $ $ast}}{{end}}{{end}}{{end}}{{/* --------------------------------------- */}}{{if and $filtered (not (or .PDoc .PAst))}}No match found. {{end}}{{with .PDoc}}{{if $.IsMain}}COMMAND DOCUMENTATION {{comment_text .Doc " " "\t"}} {{else}}{{if not $filtered}}PACKAGE DOCUMENTATION package {{.Name}} import "{{.ImportPath}}" {{comment_text .Doc " " "\t"}} {{example_text $ "" " "}}{{end}}{{/* --------------------------------------- */}}{{with .Consts}}{{if not $filtered}}CONSTANTS {{end}}{{range .}}{{node $ .Decl}} {{comment_text .Doc " " "\t"}} {{end}}{{end}}{{/* --------------------------------------- */}}{{with .Vars}}{{if not $filtered}}VARIABLES {{end}}{{range .}}{{node $ .Decl}} {{comment_text .Doc " " "\t"}} {{end}}{{end}}{{/* --------------------------------------- */}}{{with .Funcs}}{{if not $filtered}}FUNCTIONS {{end}}{{range .}}{{node $ .Decl}} {{comment_text .Doc " " "\t"}} {{example_text $ .Name " "}}{{end}}{{end}}{{/* --------------------------------------- */}}{{with .Types}}{{if not $filtered}}TYPES {{end}}{{range .}}{{$tname := .Name}}{{node $ .Decl}} {{comment_text .Doc " " "\t"}} {{/* --------------------------------------- */}}{{if .Consts}}{{range .Consts}}{{node $ .Decl}} {{comment_text .Doc " " "\t"}} {{end}}{{end}}{{/* --------------------------------------- */}}{{if .Vars}}{{range .Vars}}{{node $ .Decl}} {{comment_text .Doc " " "\t"}} {{example_text $ .Name " "}}{{end}}{{end}}{{/* --------------------------------------- */}}{{if .Funcs}}{{range .Funcs}}{{node $ .Decl}} {{comment_text .Doc " " "\t"}} {{example_text $ .Name " "}}{{end}}{{end}}{{/* --------------------------------------- */}}{{if .Methods}}{{range .Methods}}{{node $ .Decl}} {{comment_text .Doc " " "\t"}} {{$name := printf "%s_%s" $tname .Name}}{{example_text $ $name " "}}{{end}}{{end}}{{/* --------------------------------------- */}}{{end}}{{end}}{{/* --------------------------------------- */}}{{if and $filtered (not (or .Consts (or .Vars (or .Funcs .Types))))}}No match found. {{end}}{{/* --------------------------------------- */}}{{end}}{{/* --------------------------------------- */}}{{with $.Notes}} {{range $marker, $content := .}} {{$marker}}S {{range $content}}{{comment_text .Body " " "\t"}} {{end}}{{end}}{{end}}{{end}}{{/* --------------------------------------- */}}{{if not $filtered}}{{with .Dirs}}SUBDIRECTORIES {{if $.DirFlat}}{{range .List}}{{if .HasPkg}} {{.Path}}{{end}}{{end}} {{else}}{{range .List}} {{repeat ` + "`" + `. ` + "`" + ` .Depth}}{{.Name}}{{end}} {{end}}{{end}}{{/* --------------------------------------- */}}{{end}}{{/* Make sure there is no newline at the end of this file. perl -i -pe 'chomp if eof' package.txt */}} `, "play.js": `// Copyright 2012 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. function initPlayground(transport) { "use strict"; function text(node) { var s = ""; for (var i = 0; i < node.childNodes.length; i++) { var n = node.childNodes[i]; if (n.nodeType === 1) { if (n.tagName === "BUTTON") continue if (n.tagName === "SPAN" && n.className === "number") continue; if (n.tagName === "DIV" || n.tagName == "BR") { s += "\n"; } s += text(n); continue; } if (n.nodeType === 3) { s += n.nodeValue; } } return s.replace("\xA0", " "); // replace non-breaking spaces } function init(code) { var output = document.createElement('div'); var outpre = document.createElement('pre'); var running; if ($ && $(output).resizable) { $(output).resizable({ handles: "n,w,nw", minHeight: 27, minWidth: 135, maxHeight: 608, maxWidth: 990 }); } function onKill() { if (running) running.Kill(); } function onRun(e) { onKill(); output.style.display = "block"; outpre.innerHTML = ""; run1.style.display = "none"; var options = {Race: e.shiftKey}; running = transport.Run(text(code), PlaygroundOutput(outpre), options); } function onClose() { onKill(); output.style.display = "none"; run1.style.display = "inline-block"; } var run1 = document.createElement('button'); run1.innerHTML = 'Run'; run1.className = 'run'; run1.addEventListener("click", onRun, false); var run2 = document.createElement('button'); run2.className = 'run'; run2.innerHTML = 'Run'; run2.addEventListener("click", onRun, false); var kill = document.createElement('button'); kill.className = 'kill'; kill.innerHTML = 'Kill'; kill.addEventListener("click", onKill, false); var close = document.createElement('button'); close.className = 'close'; close.innerHTML = 'Close'; close.addEventListener("click", onClose, false); var button = document.createElement('div'); button.classList.add('buttons'); button.appendChild(run1); // Hack to simulate insertAfter code.parentNode.insertBefore(button, code.nextSibling); var buttons = document.createElement('div'); buttons.classList.add('buttons'); buttons.appendChild(run2); buttons.appendChild(kill); buttons.appendChild(close); output.classList.add('output'); output.appendChild(buttons); output.appendChild(outpre); output.style.display = "none"; code.parentNode.insertBefore(output, button.nextSibling); } var play = document.querySelectorAll('div.playground'); for (var i = 0; i < play.length; i++) { init(play[i]); } } `, "playground.js": `// Copyright 2012 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. /* In the absence of any formal way to specify interfaces in JavaScript, here's a skeleton implementation of a playground transport. function Transport() { // Set up any transport state (eg, make a websocket connnection). return { Run: function(body, output, options) { // Compile and run the program 'body' with 'options'. // Call the 'output' callback to display program output. return { Kill: function() { // Kill the running program. } }; } }; } // The output callback is called multiple times, and each time it is // passed an object of this form. var write = { Kind: 'string', // 'start', 'stdout', 'stderr', 'end' Body: 'string' // content of write or end status message } // The first call must be of Kind 'start' with no body. // Subsequent calls may be of Kind 'stdout' or 'stderr' // and must have a non-null Body string. // The final call should be of Kind 'end' with an optional // Body string, signifying a failure ("killed", for example). // The output callback must be of this form. // See PlaygroundOutput (below) for an implementation. function outputCallback(write) { } */ function HTTPTransport() { 'use strict'; // TODO(adg): support stderr function playback(output, events) { var timeout; output({Kind: 'start'}); function next() { if (events.length === 0) { output({Kind: 'end'}); return; } var e = events.shift(); if (e.Delay === 0) { output({Kind: 'stdout', Body: e.Message}); next(); return; } timeout = setTimeout(function() { output({Kind: 'stdout', Body: e.Message}); next(); }, e.Delay / 1000000); } next(); return { Stop: function() { clearTimeout(timeout); } } } function error(output, msg) { output({Kind: 'start'}); output({Kind: 'stderr', Body: msg}); output({Kind: 'end'}); } var seq = 0; return { Run: function(body, output, options) { seq++; var cur = seq; var playing; $.ajax('/compile', { type: 'POST', data: {'version': 2, 'body': body}, dataType: 'json', success: function(data) { if (seq != cur) return; if (!data) return; if (playing != null) playing.Stop(); if (data.Errors) { error(output, data.Errors); return; } playing = playback(output, data.Events); }, error: function() { error(output, 'Error communicating with remote server.'); } }); return { Kill: function() { if (playing != null) playing.Stop(); output({Kind: 'end', Body: 'killed'}); } }; } }; } function SocketTransport() { 'use strict'; var id = 0; var outputs = {}; var started = {}; var websocket = new WebSocket('ws://' + window.location.host + '/socket'); websocket.onclose = function() { console.log('websocket connection closed'); } websocket.onmessage = function(e) { var m = JSON.parse(e.data); var output = outputs[m.Id]; if (output === null) return; if (!started[m.Id]) { output({Kind: 'start'}); started[m.Id] = true; } output({Kind: m.Kind, Body: m.Body}); } function send(m) { websocket.send(JSON.stringify(m)); } return { Run: function(body, output, options) { var thisID = id+''; id++; outputs[thisID] = output; send({Id: thisID, Kind: 'run', Body: body, Options: options}); return { Kill: function() { send({Id: thisID, Kind: 'kill'}); } }; } }; } function PlaygroundOutput(el) { 'use strict'; return function(write) { if (write.Kind == 'start') { el.innerHTML = ''; return; } var cl = 'system'; if (write.Kind == 'stdout' || write.Kind == 'stderr') cl = write.Kind; var m = write.Body; if (write.Kind == 'end') m = '\nProgram exited' + (m?(': '+m):'.'); if (m.indexOf('IMAGE:') === 0) { // TODO(adg): buffer all writes before creating image var url = 'data:image/png;base64,' + m.substr(6); var img = document.createElement('img'); img.src = url; el.appendChild(img); return; } // ^L clears the screen. var s = m.split('\x0c'); if (s.length > 1) { el.innerHTML = ''; m = s.pop(); } m = m.replace(/&/g, '&'); m = m.replace(//g, '>'); var needScroll = (el.scrollTop + el.offsetHeight) == el.scrollHeight; var span = document.createElement('span'); span.className = cl; span.innerHTML = m; el.appendChild(span); if (needScroll) el.scrollTop = el.scrollHeight - el.offsetHeight; } } (function() { function lineHighlight(error) { var regex = /prog.go:([0-9]+)/g; var r = regex.exec(error); while (r) { $(".lines div").eq(r[1]-1).addClass("lineerror"); r = regex.exec(error); } } function highlightOutput(wrappedOutput) { return function(write) { if (write.Body) lineHighlight(write.Body); wrappedOutput(write); } } function lineClear() { $(".lineerror").removeClass("lineerror"); } // opts is an object with these keys // codeEl - code editor element // outputEl - program output element // runEl - run button element // fmtEl - fmt button element (optional) // fmtImportEl - fmt "imports" checkbox element (optional) // shareEl - share button element (optional) // shareURLEl - share URL text input element (optional) // shareRedirect - base URL to redirect to on share (optional) // toysEl - toys select element (optional) // enableHistory - enable using HTML5 history API (optional) // transport - playground transport to use (default is HTTPTransport) function playground(opts) { var code = $(opts.codeEl); var transport = opts['transport'] || new HTTPTransport(); var running; // autoindent helpers. function insertTabs(n) { // find the selection start and end var start = code[0].selectionStart; var end = code[0].selectionEnd; // split the textarea content into two, and insert n tabs var v = code[0].value; var u = v.substr(0, start); for (var i=0; i{{html .}}
{{end}} {{with .Alt}}Did you mean: {{range .Alts}} {{html .}} {{end}}
{{end}} `, "search.txt": `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 */}}{{/* --------------------------------------- */}}{{range $key, $val := .Idents}}{{if $val}}{{$key.Name}} {{range $val.Idents}} {{.Path}}.{{.Name}} {{end}} {{end}}{{end}}{{/* .Idents */}}{{/* --------------------------------------- */}}{{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}} `, "searchcode.html": ` {{$query_url := urlquery .Query}} {{if not .Idents}} {{with .Pak}}Package {{html $.Query}}
{{$pkg_html}} |
Package-level declarations
{{range .}} {{$pkg_html := pkgLink .Pak.Path | html}}package {{html .Pak.Name}}
{{range .Files}} {{$file := .File.Path}} {{range .Groups}} {{range .}} {{$line := infoLine .}} {{$file}}:{{$line}} {{infoSnippet_html .}} {{end}} {{end}} {{end}} {{end}} {{end}} {{with .Others}}Local declarations and uses
{{range .}} {{$pkg_html := pkgLink .Pak.Path | html}}package {{html .Pak.Name}}
{{range .Files}} {{$file := .File.Path}} {{$file}}{{index . 0 | infoKind_html}} | {{range .}} {{$line := infoLine .}} {{$line}} {{end}} |
---|
{{$key.Name}}
{{range $val}} {{$pkg_html := pkgLink .Path | html}} {{if eq "Packages" $key.Name}} {{html .Path}} {{else}} {{$doc_html := docLink .Path .Name| html}} {{html .Package}}.{{.Name}} {{end}} {{if .Doc}}{{comment_html .Doc}}
{{else}}No documentation available
{{end}} {{end}} {{end}} {{end}} `, "searchtxt.html": ` {{$query_url := urlquery .Query}} {{with .Textual}} {{if $.Complete}}{{html $.Found}} textual occurrences
{{else}}More than {{html $.Found}} textual occurrences
Not all files or lines containing "{{html $.Query}}" are shown.
{{end}}
{{$file}}: | {{len .Lines}} | {{range .Lines}} {{html .}} {{end}} {{if not $.Complete}} ... {{end}} | ||
---|---|---|---|---|
... |
{{end}} {{.XML}}