Commit 698c6c00 authored by Larry Hosken's avatar Larry Hosken

A step towards "externalizing" some Go docs.

+ style sheet: like code.google.com but less feature-ful
+ JS with table-of-contents generation
+ tweaked go_spec.html and go_mem.html to use new style+JS
+ static-HTML-ified a few other Go docs:
  + static HTML versions of some wiki pages (which I'll turn
    into links to these pages).

A notable thing that is _not_ in this changelist: any change
to the godoc tool or whatever thing generates http://go/godoc

R=r
APPROVED=r
DELTA=2472  (2307 added, 113 deleted, 52 changed)
OCL=34644
CL=34728
parent 229e9761
This diff is collapsed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/transitional.dtd">
<html>
<head>
<h1>The Go memory model</h1> <!--
To convert <h2>Foo</h2> into <h2 id="Foo">Foo</h2>
and convert §Foo into §<a href="#Foo">Foo</a>:
Edit ,s/<(h.)>(.*)(<\/h.>)/<\1 id="\2">\2\3/g
Edit ,x g/id="/ x/id="[^"]+"/ s/ /_/g
Edit ,s/§([^),.]+)/§<a href="#\1">\1<\/a>/g
Edit ,x/href="#[^"]+"/ s/ /_/g
-->
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>The Go Memory Model</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="godocs.js"></script>
</head>
<body>
<div id="topnav">
<table summary=""><tr>
<td id="headerImage">
<a href="./"><img src="./logo_blue.png" height="44" width="120" alt="Go Home Page" style="border:0" /></a>
</td>
<td id="headerDocSetTitle">The Go Progrmming Language</td>
</tr>
</table>
</div>
<div id="linkList">
<ul>
<li class="navhead">Related Guides</li>
<li><a href="go_spec.html">Language Specification</a></li>
<li class="blank">&nbsp;</li>
<li class="navhead">Other Resources</li>
<li><a href="./">Go Docs</a></li>
</ul>
</div>
<div id="content">
<h1 id="The_Go_Programming_Language_Specification">The Go Memory Model</h1>
<!-- The Table of Contents is automatically inserted in this <div>.
Do not delete this <div>. -->
<div id="nav"></div>
<h2>Introduction</h2> <h2>Introduction</h2>
...@@ -453,6 +505,15 @@ In all these examples, the solution is the same: ...@@ -453,6 +505,15 @@ In all these examples, the solution is the same:
use explicit synchronization. use explicit synchronization.
</p> </p>
</div>
<div id="footer">
<p>Except as noted, this content is
licensed under <a href="http://creativecommons.org/licenses/by/3.0/">
Creative Commons Attribution 3.0</a>.
</div>
</body> </body>
</html> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/transitional.dtd">
<html>
<head>
<!--
To convert <h2>Foo</h2> into <h2 id="Foo">Foo</h2>
and convert §Foo into §<a href="#Foo">Foo</a>:
Edit ,s/<(h.)>(.*)(<\/h.>)/<\1 id="\2">\2\3/g
Edit ,x g/id="/ x/id="[^"]+"/ s/ /_/g
Edit ,s/§([^),.]+)/§<a href="#\1">\1<\/a>/g
Edit ,x/href="#[^"]+"/ s/ /_/g
-->
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>The Go Programming Language Specification</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="godocs.js"></script>
</head>
<body>
<div id="topnav">
<table summary=""><tr>
<td id="headerImage">
<a href="./"><img src="./logo_blue.png" height="44" width="120" alt="Go Home Page" style="border:0" /></a>
</td>
<td id="headerDocSetTitle">The Go Programming Language</td>
</tr>
</table>
</div>
<div id="linkList">
<ul>
<li class="navhead">Related Guides</li>
<li><a href="go_tutorial.html">Tutorial</a></li>
<li><a href="go_for_cpp_programmers.html">Go for C++ Programmers</a></li>
<li class="blank">&nbsp;</li>
<li class="navhead">Other Resources</li>
<li><a href="./">Go Docs</a></li>
<li><a href="/pkg">Library documentation</a></li>
<li><a href="go_faq.html">FAQ</a></li>
</ul>
</div>
<div id="content">
<h1 id="The_Go_Programming_Language_Specification">The Go Programming Language Specification</h1>
<!-- The Table of Contents is automatically inserted in this <div>.
Do not delete this <div>. -->
<div id="nav"></div>
<!-- <!--
Open issues: Open issues:
[ ] Semantics of type declaration: [ ] Semantics of type declaration:
...@@ -47,7 +103,7 @@ compile/link model to generate executable binaries. ...@@ -47,7 +103,7 @@ compile/link model to generate executable binaries.
The grammar is compact and regular, allowing for easy analysis by The grammar is compact and regular, allowing for easy analysis by
automatic tools such as integrated development environments. automatic tools such as integrated development environments.
</p> </p>
<hr/>
<h2 id="Notation">Notation</h2> <h2 id="Notation">Notation</h2>
<p> <p>
The syntax is specified using Extended Backus-Naur Form (EBNF): The syntax is specified using Extended Backus-Naur Form (EBNF):
...@@ -85,8 +141,6 @@ The form <code>a ... b</code> represents the set of characters from ...@@ -85,8 +141,6 @@ The form <code>a ... b</code> represents the set of characters from
<code>a</code> through <code>b</code> as alternatives. <code>a</code> through <code>b</code> as alternatives.
</p> </p>
<hr/>
<h2 id="Source_code_representation">Source code representation</h2> <h2 id="Source_code_representation">Source code representation</h2>
<p> <p>
...@@ -131,7 +185,6 @@ decimal_digit = "0" ... "9" . ...@@ -131,7 +185,6 @@ decimal_digit = "0" ... "9" .
octal_digit = "0" ... "7" . octal_digit = "0" ... "7" .
hex_digit = "0" ... "9" | "A" ... "F" | "a" ... "f" . hex_digit = "0" ... "9" | "A" ... "F" | "a" ... "f" .
</pre> </pre>
<hr/>
<h2 id="Lexical_elements">Lexical elements</h2> <h2 id="Lexical_elements">Lexical elements</h2>
...@@ -432,7 +485,6 @@ an error if placed in a character literal (it is not a single code ...@@ -432,7 +485,6 @@ an error if placed in a character literal (it is not a single code
point), and will appear as two code points if placed in a string point), and will appear as two code points if placed in a string
literal. literal.
</p> </p>
<hr/>
<h3 id="Boolean_literals">Boolean literals</h3> <h3 id="Boolean_literals">Boolean literals</h3>
...@@ -1240,8 +1292,6 @@ Interface values may be compared if they have compatible static types. ...@@ -1240,8 +1292,6 @@ Interface values may be compared if they have compatible static types.
They will be equal only if they have the same dynamic type and the underlying values are equal. They will be equal only if they have the same dynamic type and the underlying values are equal.
</li> </li>
</ul> </ul>
<hr/>
<h2 id="Blocks">Blocks</h2> <h2 id="Blocks">Blocks</h2>
...@@ -3032,8 +3082,6 @@ and indexing of <code>x</code> and the evaluation ...@@ -3032,8 +3082,6 @@ and indexing of <code>x</code> and the evaluation
of <code>y</code> is not specified. of <code>y</code> is not specified.
</p> </p>
<hr/>
<h2 id="Statements">Statements</h2> <h2 id="Statements">Statements</h2>
<p> <p>
...@@ -3851,8 +3899,6 @@ for i := 0; i &lt;= 3; i++ { ...@@ -3851,8 +3899,6 @@ for i := 0; i &lt;= 3; i++ {
} }
</pre> </pre>
<hr/>
<h2 id="Predeclared_functions">Predeclared functions</h2> <h2 id="Predeclared_functions">Predeclared functions</h2>
<ul> <ul>
<li>cap <li>cap
...@@ -4065,8 +4111,6 @@ m := make(map[string] int, 100); # map with initial space for 100 elements ...@@ -4065,8 +4111,6 @@ m := make(map[string] int, 100); # map with initial space for 100 elements
<font color=red>TODO: Need syntax that permits a type as first argument for built-ins.</font> <font color=red>TODO: Need syntax that permits a type as first argument for built-ins.</font>
</p> </p>
<hr/>
<h2 id="Packages">Packages</h2> <h2 id="Packages">Packages</h2>
<p> <p>
...@@ -4235,8 +4279,6 @@ func main() { ...@@ -4235,8 +4279,6 @@ func main() {
} }
</pre> </pre>
<hr/>
<h2 id="Program_initialization_and_execution">Program initialization and execution</h2> <h2 id="Program_initialization_and_execution">Program initialization and execution</h2>
<h3 id="The_zero_value">The zero value</h3> <h3 id="The_zero_value">The zero value</h3>
...@@ -4367,8 +4409,6 @@ Implementation restriction: The compiler assumes package <code>main</code> ...@@ -4367,8 +4409,6 @@ Implementation restriction: The compiler assumes package <code>main</code>
is not imported by any other package. is not imported by any other package.
</p> </p>
<hr/>
<h2 id="System_considerations">System considerations</h2> <h2 id="System_considerations">System considerations</h2>
<h3 id="Package_unsafe">Package <code>unsafe</code></h3> <h3 id="Package_unsafe">Package <code>unsafe</code></h3>
...@@ -4480,8 +4520,6 @@ The following minimal alignment properties are guaranteed: ...@@ -4480,8 +4520,6 @@ The following minimal alignment properties are guaranteed:
<code>unsafe.Alignof(x[0])</code>, but at least 1. <code>unsafe.Alignof(x[0])</code>, but at least 1.
</ol> </ol>
<hr/>
<h2 id="Implementation_differences"><font color=red>Implementation differences - TODO</font></h2> <h2 id="Implementation_differences"><font color=red>Implementation differences - TODO</font></h2>
<ul> <ul>
<li><font color=red>Implementation does not honor the restriction on goto statements and targets (no intervening declarations).</font></li> <li><font color=red>Implementation does not honor the restriction on goto statements and targets (no intervening declarations).</font></li>
...@@ -4490,5 +4528,12 @@ The following minimal alignment properties are guaranteed: ...@@ -4490,5 +4528,12 @@ The following minimal alignment properties are guaranteed:
</ul> </ul>
</div> </div>
<div id="footer">
<p>Except as noted, this content is
licensed under <a href="http://creativecommons.org/licenses/by/3.0/">
Creative Commons Attribution 3.0</a>.
</div>
</body> </body>
</html> </html>
// Except as noted, this content is licensed under Creative Commons
// Attribution 3.0
/* A little code to ease navigation of these documents.
*
* On window load we:
* + Generate a table of contents (godocs_generateTOC)
* + Add links up to the top of the doc from each section (godocs_addTopLinks)
*/
/* We want to do some stuff on page load (after the HTML is rendered).
So listen for that:
*/
if (window.addEventListener){
window.addEventListener('load', godocs_onload, false);
} else if (elm.attachEvent){
window.attachEvent('onload', godocs_onload);
}
function godocs_onload() {
godocs_generateTOC();
godocs_addTopLinks();
}
/* Generates a table of contents: looks for h2 and h3 elements and generates
* links. "Decorates" the element with id=="nav" with this table of contents.
*/
function godocs_generateTOC() {
var navbar = document.getElementById('nav');
if (!navbar) { return; }
var toc_items = [];
var i;
for (i = 0; i < navbar.parentNode.childNodes.length; i++) {
var node = navbar.parentNode.childNodes[i];
if ((node.tagName == 'h2') || (node.tagName == 'H2')) {
if (!node.id) {
node.id = 'tmp_' + i;
}
var text = godocs_nodeToText(node);
if (!text) { continue; }
var textNode = document.createTextNode(text);
var link = document.createElement('a');
link.href = '#' + node.id;
link.appendChild(textNode);
// Then create the item itself
var item = document.createElement('dt');
item.appendChild(link);
toc_items.push(item);
}
if ((node.tagName == 'h3') || (node.tagName == 'H3')) {
if (!node.id) {
node.id = 'tmp_' + i;
}
var text = godocs_nodeToText(node);
if (!text) { continue; }
var textNode = document.createTextNode(text);
var link = document.createElement('a');
link.href = '#' + node.id;
link.appendChild(textNode);
// Then create the item itself
var item = document.createElement('dd');
item.appendChild(link);
toc_items.push(item);
}
}
if (!toc_items.length) { return; }
var dl1 = document.createElement('dl');
var dl2 = document.createElement('dl');
var split_index = (toc_items.length / 2) + 1;
if (split_index < 8) {
split_index = toc_items.length;
}
for (i = 0; i < split_index; i++) {
dl1.appendChild(toc_items[i]);
}
for (/* keep using i */; i < toc_items.length; i++) {
dl2.appendChild(toc_items[i]);
}
var tocTable = document.createElement('table');
navbar.appendChild(tocTable);
tocTable.className = 'unruled';
var tocBody = document.createElement('tbody');
tocTable.appendChild(tocBody);
var tocRow = document.createElement('tr');
tocBody.appendChild(tocRow);
// 1st column
var tocCell = document.createElement('td');
tocCell.className = 'first';
tocRow.appendChild(tocCell);
tocCell.appendChild(dl1);
// 2nd column
tocCell = document.createElement('td');
tocRow.appendChild(tocCell);
tocCell.appendChild(dl2);
}
/* Returns the "This sweet header" from <h2>This <i>sweet</i> header</h2>.
* Takes a node, returns a string.
*/
function godocs_nodeToText(node) {
var TEXT_NODE = 3; // Defined in Mozilla but not MSIE :(
var text = '';
for (var j = 0; j != node.childNodes.length; j++) {
var child = node.childNodes[j];
if (child.nodeType == TEXT_NODE) {
if (child.nodeValue != '[Top]') { //ok, that's a hack, but it works.
text = text + child.nodeValue;
}
} else {
text = text + godocs_nodeToText(child);
}
}
return text;
}
/* For each H2 heading, add a link up to the #top of the document.
* (As part of this: ensure existence of 'top' named anchor link
* (theoretically at doc's top).)
*/
function godocs_addTopLinks() {
/* Make sure there's a "top" to link to. */
var top = document.getElementById('top');
if (!top) {
document.body.id = 'top';
}
if (!document.getElementsByTagName) return; // no browser support
var headers = document.getElementsByTagName('h2');
for (var i = 0; i < headers.length; i++) {
var span = document.createElement('span');
span.className = 'navtop';
var link = document.createElement('a');
span.appendChild(link);
link.href = '#top';
var textNode = document.createTextNode('[Top]');
link.appendChild(textNode);
headers[i].appendChild(span);
}
}
code, .code {
font-size: 9pt;
font-family: Courier, Courier New, monospace;
color:#007000;
}
kbd {
font-family: Courier, Courier New, monospace;
font-weight: bold;
}
pre.ebnf {
background-color: beige;
}
pre.grammar {
background-color: beige;
}
p.rule {
font-style: italic
}
span.event {
font-style: italic
}
body {
font: 13px Helvetica, Arial, sans-serif;
}
h1, h2, h3, h4, h5, h6 {
font-family: Helvetica, Arial, sans-serif;
margin-bottom: 0.25em;
}
h2 {
background-color: #e5ecf9;
margin-top: 2em;
border-top:1px solid #36C;
}
pre{
font-size: 9pt;
background-color: #fafaff;
margin: 1em 0 0 0;
padding: .99em;
line-height: 125%;
overflow: auto;
word-wrap: break-word;
}
li {
padding-bottom: 0.5em;
}
li pre {
margin: 0.5em 0px 1em 0px;
}
/* Above this comment, styles meant to help page authors achieve beauty. */
/* Below this comment, styles used in the boilerplate-ish parts of pages. */
div#content {
margin-left: 20%;
padding: 0 1em 2em 1em;
margin-top: -2px;
border: 2px solid #e5ecf9;
}
#topnav {
margin: 0px;
padding: .1em 0px;
width: 100%;
white-space: nowrap;
background-color: #e5ecf9;
border-top:1px solid #36C;
font: bold large Helvetica, Arial, sans-serif;
}
div#linkList {
font: 13px Helvetica, Arial, sans-serif;
float: left;
width: 20%;
}
div#linkList ul {
padding: 1px;
list-style-type: none;
}
div#linkList li {
margin-left: 1em;
}
div#linkList li.navhead {
font-weight: bold;
margin-left: 0px;
}
#nav dl {
margin: 0 0.5em 0 0.5em;
padding: 0px;
}
.navtop {
font-size: xx-small;
float: right;
}
#footer {
margin: 2em;
text-align: center;
color: #555;
font-size: small;
}
#footer a {
color: #555;
}
@media print {
div#linkList {
display: none;
}
.navtop {
display: none;
}
div#content {
margin-left: 0px;
border: none;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment