Commit 3601f277 authored by Robert Griesemer's avatar Robert Griesemer

godoc: make id attributes unique

Some browsers (e.g. IE9) ignore the case of 'id' attributes
which can lead to conflicts. Prefix non-generated 'id's with
"pkg-" to make them different from any generated attribute.

Also: Added missing entry for "Other packages" to top-level
index.

Fixes #3851.

R=adg, dsymonds
CC=golang-dev
https://golang.org/cl/6449105
parent fca45719
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
Use of this source code is governed by a BSD-style Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file. 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}} {{with .PDoc}}
{{if $.IsPkg}} {{if $.IsPkg}}
<div id="short-nav"> <div id="short-nav">
...@@ -10,18 +16,21 @@ ...@@ -10,18 +16,21 @@
<dd><code>import "{{html .ImportPath}}"</code></dd> <dd><code>import "{{html .ImportPath}}"</code></dd>
</dl> </dl>
<dl> <dl>
<dd><a href="#overview" class="overviewLink">Overview</a></dd> <dd><a href="#pkg-overview" class="overviewLink">Overview</a></dd>
<dd><a href="#index">Index</a></dd> <dd><a href="#pkg-index">Index</a></dd>
{{if $.Examples}} {{if $.Examples}}
<dd><a href="#examples">Examples</a></dd> <dd><a href="#pkg-examples">Examples</a></dd>
{{end}}
{{if $.PList}}
<dd><a href="#pkg-other-packages">Other packages</a></dd>
{{end}} {{end}}
{{if $.Dirs}} {{if $.Dirs}}
<dd><a href="#subdirectories">Subdirectories</a></dd> <dd><a href="#pkg-subdirectories">Subdirectories</a></dd>
{{end}} {{end}}
</dl> </dl>
</div> </div>
<!-- The package's Name is printed as title by the top-level template --> <!-- The package's Name is printed as title by the top-level template -->
<div id="overview" class="toggleVisible"> <div id="pkg-overview" class="toggleVisible">
<div class="collapsed"> <div class="collapsed">
<h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2> <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
</div> </div>
...@@ -32,15 +41,15 @@ ...@@ -32,15 +41,15 @@
</div> </div>
{{example_html "" $.Examples $.FSet}} {{example_html "" $.Examples $.FSet}}
<h2 id="index">Index</h2> <h2 id="pkg-index">Index</h2>
<!-- Table of contents for API; must be named manual-nav to turn off auto nav. --> <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
<div id="manual-nav"> <div id="manual-nav">
<dl> <dl>
{{if .Consts}} {{if .Consts}}
<dd><a href="#constants">Constants</a></dd> <dd><a href="#pkg-constants">Constants</a></dd>
{{end}} {{end}}
{{if .Vars}} {{if .Vars}}
<dd><a href="#variables">Variables</a></dd> <dd><a href="#pkg-variables">Variables</a></dd>
{{end}} {{end}}
{{range .Funcs}} {{range .Funcs}}
{{$name_html := html .Name}} {{$name_html := html .Name}}
...@@ -59,12 +68,12 @@ ...@@ -59,12 +68,12 @@
{{end}} {{end}}
{{end}} {{end}}
{{if .Bugs}} {{if .Bugs}}
<dd><a href="#bugs">Bugs</a></dd> <dd><a href="#pkg-bugs">Bugs</a></dd>
{{end}} {{end}}
</dl> </dl>
{{if $.Examples}} {{if $.Examples}}
<h4 id="examples">Examples</h4> <h4 id="pkg-examples">Examples</h4>
<dl> <dl>
{{range $.Examples}} {{range $.Examples}}
<dd><a class="exampleLink" href="#example_{{.Name}}">{{example_name .Name}}</a></dd> <dd><a class="exampleLink" href="#example_{{.Name}}">{{example_name .Name}}</a></dd>
...@@ -84,14 +93,14 @@ ...@@ -84,14 +93,14 @@
{{end}} {{end}}
{{with .Consts}} {{with .Consts}}
<h2 id="constants">Constants</h2> <h2 id="pkg-constants">Constants</h2>
{{range .}} {{range .}}
<pre>{{node_html .Decl $.FSet}}</pre> <pre>{{node_html .Decl $.FSet}}</pre>
{{comment_html .Doc}} {{comment_html .Doc}}
{{end}} {{end}}
{{end}} {{end}}
{{with .Vars}} {{with .Vars}}
<h2 id="variables">Variables</h2> <h2 id="pkg-variables">Variables</h2>
{{range .}} {{range .}}
<pre>{{node_html .Decl $.FSet}}</pre> <pre>{{node_html .Decl $.FSet}}</pre>
{{comment_html .Doc}} {{comment_html .Doc}}
...@@ -147,7 +156,7 @@ ...@@ -147,7 +156,7 @@
{{end}} {{end}}
{{with .Bugs}} {{with .Bugs}}
<h2 id="bugs">Bugs</h2> <h2 id="pkg-bugs">Bugs</h2>
{{range .}} {{range .}}
{{comment_html .}} {{comment_html .}}
{{end}} {{end}}
...@@ -159,7 +168,7 @@ ...@@ -159,7 +168,7 @@
{{end}} {{end}}
{{with .PList}} {{with .PList}}
<h2>Other packages</h2> <h2 id="pkg-other-packages">Other packages</h2>
<p> <p>
{{/* PList entries are strings - no need for FSet */}} {{/* PList entries are strings - no need for FSet */}}
{{range .}} {{range .}}
...@@ -171,7 +180,7 @@ ...@@ -171,7 +180,7 @@
{{with .Dirs}} {{with .Dirs}}
{{/* DirList entries are numbers and strings - no need for FSet */}} {{/* DirList entries are numbers and strings - no need for FSet */}}
{{if $.PDoc}} {{if $.PDoc}}
<h2 id="subdirectories">Subdirectories</h2> <h2 id="pkg-subdirectories">Subdirectories</h2>
{{else}} {{else}}
<div class="pkgGopher"> <div class="pkgGopher">
<img class="gopher" src="/doc/gopher/pkg.png"/> <img class="gopher" src="/doc/gopher/pkg.png"/>
......
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