Compare commits

...

12 Commits

Author SHA1 Message Date
Andrew Gerrand b5e7da4a16 [release-branch.go1.3] go.tools/godoc: remove Google+ buttons
««« CL 138180043 / 9b1966d73f3f
go.tools/godoc: remove Google+ buttons

LGTM=bradfitz
R=golang-codereviews, bradfitz, dsymonds
CC=golang-codereviews
https://golang.org/cl/138180043
»»»

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/165390043
2014-11-03 15:20:02 +11:00
Andrew Gerrand e3235480e7 [release-branch.go1.3] go.tools/cmd/godoc: add handlers for new sub-repo paths
««« CL 162470043 / 1e73f4eb4c15
go.tools/cmd/godoc: add handlers for new sub-repo paths

Fixes golang/go#9009.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/162470043
»»»

TBR=rsc
CC=golang-codereviews
https://golang.org/cl/171800043
2014-11-02 10:54:05 +11:00
Andrew Gerrand 0f9e347959 [release-branch.go1.3] go.tools/present: allow intentionally empty parameters
««« CL 105070043 / 1e6e75afb0cd
go.tools/present: allow intentionally empty parameters

Fixes golang/go#7613.

LGTM=r
R=adg, r
CC=golang-codereviews
https://golang.org/cl/105070043

»»»

LGTM=dsymonds
R=dsymonds
CC=golang-codereviews
https://golang.org/cl/148300043
2014-09-29 13:55:37 +10:00
Andrew Gerrand 84ece76229 [release-branch.go1.3] go.tools/godoc: mention sub-repos and package indexes on packages page
««« CL 128490043 / 99ba754ccda0
go.tools/godoc: mention sub-repos and package indexes on packages page

Also several cosmetic tweaks to the package page.

LGTM=r, bradfitz
R=bradfitz, r
CC=golang-codereviews
https://golang.org/cl/128490043
»»»

TBR=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/127630043
2014-08-21 13:14:17 +10:00
Andrew Gerrand bd92d52adb [release-branch.go1.3] go.tools/go/pointer: fix crash in constraint generation of ssa.Convert to a named unsafe.Pointer type.
««« CL 106060046 / 2ced0a1d47e3
go.tools/go/pointer: fix crash in constraint generation of ssa.Convert to a named unsafe.Pointer type.

+ test.

Fixes golang/go#8231.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/106060046
»»»

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/127060043
2014-08-12 09:24:35 +10:00
Andrew Gerrand a89089ae07 [release-branch.go1.3] go.tools/godoc: drop scheme from links
««« CL 111640043 / a2b9ff935cf3
go.tools/godoc: drop scheme from links

golang.org now serves HTTPS,
so the scripts should work
with either HTTP ot HTTPS.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/111640043
»»»

TBR=bradfitz
CC=golang-codereviews
https://golang.org/cl/112690043
2014-07-25 10:29:02 +10:00
Andrew Gerrand 3e9181fb84 [release-branch.go1.3] go.tools/godoc/static: remove unnecessary mainframe wrapper
««« CL 113130044 / c60f58db34e9
go.tools/godoc/static: remove unnecessary mainframe wrapper

Fixes golang/go#8300.

LGTM=adonovan
R=golang-codereviews, adonovan, bradfitz
CC=golang-codereviews
https://golang.org/cl/113130044
»»»

TBR=rsc
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/112510043
2014-07-21 10:14:57 +10:00
Andrew Gerrand 6949210a02 [release-branch.go1.3] go.tools/cmd/godoc: register redirect handler for /dl/
««« CL 107050044 / 85bf266ce14d
go.tools/cmd/godoc: register redirect handler for /dl/

LGTM=minux
R=golang-codereviews, gobot, bradfitz, minux
CC=golang-codereviews
https://golang.org/cl/107050044
»»»

TBR=bradfitz
CC=golang-codereviews
https://golang.org/cl/105290045
2014-06-19 05:57:11 +10:00
Andrew Gerrand 4148138891 [release-branch.go1.3] go.tools/go/types/typeutil: use reflect instead of unsafe
««« CL 105960043 / 3d86e17d25ff
go.tools/go/types/typeutil: use reflect instead of unsafe

Godoc depends on this package.
Packages that use unsafe cannot be deployed to App Engine.
Packages that use reflect can.
This package needn't use unsafe, so don't.

LGTM=adonovan, rsc
R=rsc, adonovan
CC=golang-codereviews
https://golang.org/cl/105960043
»»»

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/104130044
2014-06-15 10:00:11 +10:00
Andrew Gerrand 636df8305a [release-branch.go1.3] go.tools/cmd/godoc: set corpus.MaxResults in appinit.go
««« CL 101220045 / b1ce6f5e6073
go.tools/cmd/godoc: set corpus.MaxResults in appinit.go

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/101220045
»»»

TBR=bradfitz
CC=golang-codereviews
https://golang.org/cl/105190044
2014-06-13 16:56:00 +10:00
Andrew Gerrand 5b307dbe98 [release-branch.go1.3] go.tools/godoc: fix index reading and writing
««« CL 103370046 / 3b66a5dfbfe1
go.tools/godoc: fix index reading and writing

In command godoc, set IndexEnabled when the -write_index flag is set.
Previously you would need to (unintuitively) set the -http flag to
achieve this.

In package godoc, set up the FS tree before loading the index, and
then return before starting the index refresh loop. Previously the
index would be loaded and then immediately refreshed, negating the
benefits of the on-disk index.

TBR=bradfitz
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/103370046
»»»

TBR=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/105190043
2014-06-13 16:54:49 +10:00
Andrew Gerrand 52572e427b [release-branch.go1.3] create branch
Change some space in the README to push the change through.
2014-06-12 13:12:02 +10:00
21 changed files with 228 additions and 90 deletions

1
README
View File

@ -8,3 +8,4 @@ Packages include a type-checker for Go and an implementation of the
Static Single Assignment form (SSA) representation for Go programs.
To submit changes to this repository, see http://golang.org/doc/contribute.html.

View File

@ -43,6 +43,7 @@ func init() {
corpus := godoc.NewCorpus(fs)
corpus.Verbose = false
corpus.MaxResults = 10000 // matches flag default in main.go
corpus.IndexEnabled = true
corpus.IndexFiles = indexFilenames
if err := corpus.Init(); err != nil {

14
cmd/godoc/dl.go Normal file
View File

@ -0,0 +1,14 @@
// Copyright 2014 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.
package main
import "net/http"
// Register a redirect handler for /dl/ to the golang.org download page.
// This file will not be included when deploying godoc to golang.org.
func init() {
http.Handle("/dl/", http.RedirectHandler("http://golang.org/dl/", http.StatusFound))
}

View File

@ -221,6 +221,7 @@ func main() {
corpus.IndexThrottle = *indexThrottle
if *writeIndex {
corpus.IndexThrottle = 1.0
corpus.IndexEnabled = true
}
if *writeIndex || httpMode || *urlFlag != "" {
if err := corpus.Init(); err != nil {

68
cmd/godoc/x.go Normal file
View File

@ -0,0 +1,68 @@
// Copyright 2013 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.
// This file contains the handlers that serve go-import redirects for Go
// sub-repositories. It specifies the mapping from import paths like
// "golang.org/x/tools" to the actual repository locations.
package main
import (
"html/template"
"log"
"net/http"
"strings"
)
const xPrefix = "/x/"
var xMap = map[string]string{
"benchmarks": "https://code.google.com/p/go.benchmarks",
"blog": "https://code.google.com/p/go.blog",
"codereview": "https://code.google.com/p/go.codereview",
"crypto": "https://code.google.com/p/go.crypto",
"exp": "https://code.google.com/p/go.exp",
"image": "https://code.google.com/p/go.image",
"mobile": "https://code.google.com/p/go.mobile",
"net": "https://code.google.com/p/go.net",
"sys": "https://code.google.com/p/go.sys",
"talks": "https://code.google.com/p/go.talks",
"text": "https://code.google.com/p/go.text",
"tools": "https://code.google.com/p/go.tools",
}
func init() {
http.HandleFunc(xPrefix, xHandler)
}
func xHandler(w http.ResponseWriter, r *http.Request) {
head, tail := strings.TrimPrefix(r.URL.Path, xPrefix), ""
if i := strings.Index(head, "/"); i != -1 {
head, tail = head[:i], head[i:]
}
repo, ok := xMap[head]
if !ok {
http.NotFound(w, r)
return
}
data := struct {
Prefix, Head, Tail, Repo string
}{xPrefix, head, tail, repo}
if err := xTemplate.Execute(w, data); err != nil {
log.Println("xHandler:", err)
}
}
var xTemplate = template.Must(template.New("x").Parse(`<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="go-import" content="golang.org{{.Prefix}}{{.Head}} hg {{.Repo}}">
<meta http-equiv="refresh" content="0; url=https://godoc.org/golang.org{{.Prefix}}{{.Head}}{{.Tail}}">
</head>
<body>
Nothing to see here; <a href="https://godoc.org/golang.org{{.Prefix}}{{.Head}}{{.Tail}}">move along</a>.
</body>
</html>
`))

View File

@ -67,10 +67,12 @@ body {
border: 1px solid rgba(0, 0, 0, .3);
/*
transition: transform .3s ease-out;
-o-transition: -o-transform .3s ease-out;
-moz-transition: -moz-transform .3s ease-out;
-webkit-transition: -webkit-transform .3s ease-out;
*/
}
.slides.layout-widescreen > article {
margin-left: -550px;

View File

@ -3,7 +3,7 @@
#
# Using -V test-build will run as test-build.golang.org.
application: golang-org
application: go-build
version: build
runtime: go
api_version: go1
@ -15,7 +15,7 @@ handlers:
script: _go_app
- url: /(|gccgo/)(|commit|packages|result|perf-result|tag|todo|perf|perfdetail|perfgraph|updatebenchmark)
script: _go_app
- url: /(|gccgo/)(init|buildtest|key|perflearn|_ah/queue/go/delay)
- url: /(|gccgo/)(init|buildtest|key|perflearn|_ah/queue/go/delay|_ah/remote_api)
script: _go_app
login: admin

View File

@ -24,6 +24,8 @@ import (
"appengine/datastore"
"cache"
_ "appengine/remote_api"
)
const (

View File

@ -431,7 +431,7 @@ func (a *analysis) genConv(conv *ssa.Convert, cgn *cgnode) {
case *types.Pointer:
// *T -> unsafe.Pointer?
if tDst == tUnsafePtr {
if tDst.Underlying() == tUnsafePtr {
// ignore for now
// a.copy(res, a.valueNode(conv.X), 1)
return

View File

@ -49,9 +49,17 @@ func conv4() {
print(p) // @pointsto convert@c2p:13
}
// Regression test for b/8231.
func conv5() {
type P unsafe.Pointer
var i *struct{}
_ = P(i)
}
func main() {
conv1()
conv2()
conv3()
conv4()
conv5()
}

View File

@ -9,7 +9,7 @@ package typeutil
import (
"bytes"
"fmt"
"unsafe"
"reflect"
"code.google.com/p/go.tools/go/types"
)
@ -295,7 +295,7 @@ func (h Hasher) hashFor(t types.Type) uint32 {
case *types.Named:
// Not safe with a copying GC; objects may move.
return uint32(uintptr(unsafe.Pointer(t.Obj())))
return uint32(reflect.ValueOf(t.Obj()).Pointer())
case *types.Tuple:
return h.hashTuple(t)

View File

@ -1477,10 +1477,11 @@ func (c *Corpus) UpdateIndex() {
func (c *Corpus) RunIndexer() {
// initialize the index from disk if possible
if c.IndexFiles != "" {
c.initFSTree()
if err := c.readIndex(c.IndexFiles); err != nil {
log.Printf("error reading index from file %s: %v", c.IndexFiles, err)
return
}
return
}
// Repeatedly update the package directory tree and index.

View File

@ -254,8 +254,10 @@ func (h *handlerServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// special cases for top-level package/command directories
switch tabtitle {
case "/src/pkg":
title = "Packages"
tabtitle = "Packages"
case "/src/cmd":
title = "Commands"
tabtitle = "Commands"
}

View File

@ -16,7 +16,10 @@
</head>
<body>
<div id="mainframe" style="position: fixed; bottom: 0; top:0; overflow: auto; width: 100%;">
<div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
...
</div><!-- #lowframe -->
<div id="topbar"{{if .Title}} class="wide"{{end}}><div class="container">
<form method="GET" action="/search">
@ -58,7 +61,6 @@ func main() {
<div class="container">
{{with .Title}}
<div id="plusone"><g:plusone size="small" annotation="none"></g:plusone></div>
<h1>{{html .}}</h1>
{{end}}
{{with .Subtitle}}
@ -85,11 +87,6 @@ and code is licensed under a <a href="/LICENSE">BSD license</a>.<br>
</div><!-- .container -->
</div><!-- #page -->
</div><!-- #mainframe -->
<div id='lowframe' style="position: absolute; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
...
</div><!-- #lowframe -->
<!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
<script type="text/javascript" src="/lib/godoc/jquery.js"></script>
<script type="text/javascript" src="/lib/godoc/jquery.treeview.js"></script>

View File

@ -152,7 +152,7 @@ function setupDropdownPlayground() {
'runEl': $('.run', div),
'fmtEl': $('.fmt', div),
'shareEl': $('.share', div),
'shareRedirect': 'http://play.golang.org/p/'
'shareRedirect': '//play.golang.org/p/'
});
},
function() {
@ -176,7 +176,7 @@ function setupInlinePlayground() {
'runEl': $('.run', el),
'fmtEl': $('.fmt', el),
'shareEl': $('.share', el),
'shareRedirect': 'http://play.golang.org/p/'
'shareRedirect': '//play.golang.org/p/'
});
// Make the code textarea resize to fit content.
@ -232,15 +232,6 @@ function toggleHash() {
}
}
function addPlusButtons() {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/platform.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
}
$(document).ready(function() {
bindSearchEvents();
generateTOC();
@ -256,7 +247,6 @@ $(document).ready(function() {
setupTypeInfo();
setupCallgraphs();
toggleHash();
addPlusButtons();
// godoc.html defines window.initFuncs in the <head> tag, and root.html and
// codewalk.js push their on-page-ready functions to the list.

View File

@ -237,10 +237,18 @@
{{/* 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"/>
{{end}}
{{if eq $.Dirname "/src/pkg"}}
<div id="manual-nav">
<dl>
<dt><a href="#stdlib">Standard library</a></dt>
<dt><a href="#other">Other packages</a></dt>
<dd><a href="#subrepo">Sub-repositories</a></dd>
<dd><a href="#community">Community</a></dd>
</dl>
</div>
<h2 id="stdlib">Standard library</h2>
<img class="gopher" src="/doc/gopher/pkg.png"/>
{{end}}
<table class="dir">
<tr>
@ -248,7 +256,7 @@
<th>&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th style="text-align: left; width: auto">Synopsis</th>
</tr>
{{if not $.DirFlat}}
{{if not (or (eq $.Dirname "/src/pkg") (eq $.Dirname "/src/cmd") $.DirFlat)}}
<tr>
<td><a href="..">..</a></td>
</tr>
@ -271,7 +279,34 @@
{{end}}
{{end}}
</table>
{{if $.PDoc}}{{else}}
<p>Need more packages? Check out the <a href="/wiki/SubRepositories">sub-repositories</a> and <a href="/wiki/Projects">other Go projects</a>.</p>
{{if eq $.Dirname "/src/pkg"}}
<h2 id="other">Other packages</h2>
<h3 id="subrepo">Sub-repositories</h3>
<p>
These packages are part of the Go Project but outside the main Go tree.
They are developed under looser <a href="/doc/go1compat">compatibility requirements</a> than the Go core.
Install them with "<a href="/cmd/go/#hdr-Download_and_install_packages_and_dependencies">go get</a>".
</p>
<ul>
<li><a href="//godoc.org/code.google.com/p/go.crypto">crypto</a> — additional cryptography packages.</li>
<li><a href="//godoc.org/code.google.com/p/go.image">image</a> — additional imaging packages.</li>
<li><a href="//godoc.org/code.google.com/p/go.net">net</a> — additional networking packages.</li>
<li><a href="//godoc.org/code.google.com/p/go.sys">sys</a> — packages for making system calls.</li>
<li><a href="//godoc.org/code.google.com/p/go.text">text</a> — packages for working with text.</li>
<li><a href="//godoc.org/code.google.com/p/go.tools">tools</a> — godoc, vet, cover, and other tools.</li>
<li><a href="//godoc.org/code.google.com/p/go.exp">exp</a> — experimental code (handle with care; may change without warning).</li>
</ul>
<h3 id="community">Community</h3>
<p>
These services can help you find Open Source packages provided by the community.
</p>
<ul>
<li><a href="//godoc.org">GoDoc</a> - a package index and search engine.</li>
<li><a href="http://go-search.org">Go Search</a> - a code search engine.</li>
<li><a href="/wiki/Projects">Projects at the Go Wiki</a> - a curated list of Go projects.</li>
</ul>
{{end}}
{{end}}

File diff suppressed because one or more lines are too long

View File

@ -411,15 +411,6 @@ img.gopher {
margin-bottom: 10px;
z-index: -1;
}
.pkgGopher {
text-align: right;
}
.pkgGopher .gopher {
float: none;
position: relative;
top: -40px;
margin-bottom: -120px;
}
h2 { clear: right; }
/* example and drop-down playground */
@ -601,4 +592,4 @@ a.error {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
padding: 2px 4px 2px 4px; /* TRBL */
}
}

View File

@ -238,6 +238,8 @@ func parseArgs(name string, line int, args []string) (res []interface{}, err err
res[i] = v
case '$':
res[i] = "$"
case '_':
// Do nothing; '_' indicates an intentionally empty parameter.
default:
return nil, fmt.Errorf("%s:%d bad code argument %q", name, line, v)
}

View File

@ -168,10 +168,14 @@ The template uses the function "image" to inject picture files.
The syntax is simple: 1 or 3 space-separated arguments.
The first argument is always the file name.
If there are more arguments, they are the height and width;
both must be present.
both must be present, or substituted with an underscore.
Replacing a dimension argument with the underscore parameter
preserves the aspect ratio of the image when scaling.
.image images/betsy.jpg 100 200
.image images/janet.jpg _ 300
iframe:
The function "iframe" injects iframes (pages inside pages).

View File

@ -32,6 +32,11 @@ func parseImage(ctx *Context, fileName string, lineno int, text string) (Elem, e
case 0:
// no size parameters
case 2:
// If a parameter is empty (underscore) or invalid
// leave the field set to zero. The "image" action
// template will then omit that img tag attribute and
// the browser will calculate the value to preserve
// the aspect ratio.
if v, ok := a[0].(int); ok {
img.Height = v
}