Compare commits
12 Commits
master
...
release-br
Author | SHA1 | Date |
---|---|---|
|
b5e7da4a16 | |
|
e3235480e7 | |
|
0f9e347959 | |
|
84ece76229 | |
|
bd92d52adb | |
|
a89089ae07 | |
|
3e9181fb84 | |
|
6949210a02 | |
|
4148138891 | |
|
636df8305a | |
|
5b307dbe98 | |
|
52572e427b |
1
README
1
README
|
@ -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.
|
Static Single Assignment form (SSA) representation for Go programs.
|
||||||
|
|
||||||
To submit changes to this repository, see http://golang.org/doc/contribute.html.
|
To submit changes to this repository, see http://golang.org/doc/contribute.html.
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ func init() {
|
||||||
|
|
||||||
corpus := godoc.NewCorpus(fs)
|
corpus := godoc.NewCorpus(fs)
|
||||||
corpus.Verbose = false
|
corpus.Verbose = false
|
||||||
|
corpus.MaxResults = 10000 // matches flag default in main.go
|
||||||
corpus.IndexEnabled = true
|
corpus.IndexEnabled = true
|
||||||
corpus.IndexFiles = indexFilenames
|
corpus.IndexFiles = indexFilenames
|
||||||
if err := corpus.Init(); err != nil {
|
if err := corpus.Init(); err != nil {
|
||||||
|
|
|
@ -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))
|
||||||
|
}
|
|
@ -221,6 +221,7 @@ func main() {
|
||||||
corpus.IndexThrottle = *indexThrottle
|
corpus.IndexThrottle = *indexThrottle
|
||||||
if *writeIndex {
|
if *writeIndex {
|
||||||
corpus.IndexThrottle = 1.0
|
corpus.IndexThrottle = 1.0
|
||||||
|
corpus.IndexEnabled = true
|
||||||
}
|
}
|
||||||
if *writeIndex || httpMode || *urlFlag != "" {
|
if *writeIndex || httpMode || *urlFlag != "" {
|
||||||
if err := corpus.Init(); err != nil {
|
if err := corpus.Init(); err != nil {
|
||||||
|
|
|
@ -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>
|
||||||
|
`))
|
|
@ -67,10 +67,12 @@ body {
|
||||||
|
|
||||||
border: 1px solid rgba(0, 0, 0, .3);
|
border: 1px solid rgba(0, 0, 0, .3);
|
||||||
|
|
||||||
|
/*
|
||||||
transition: transform .3s ease-out;
|
transition: transform .3s ease-out;
|
||||||
-o-transition: -o-transform .3s ease-out;
|
-o-transition: -o-transform .3s ease-out;
|
||||||
-moz-transition: -moz-transform .3s ease-out;
|
-moz-transition: -moz-transform .3s ease-out;
|
||||||
-webkit-transition: -webkit-transform .3s ease-out;
|
-webkit-transition: -webkit-transform .3s ease-out;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
.slides.layout-widescreen > article {
|
.slides.layout-widescreen > article {
|
||||||
margin-left: -550px;
|
margin-left: -550px;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
# Using -V test-build will run as test-build.golang.org.
|
# Using -V test-build will run as test-build.golang.org.
|
||||||
|
|
||||||
application: golang-org
|
application: go-build
|
||||||
version: build
|
version: build
|
||||||
runtime: go
|
runtime: go
|
||||||
api_version: go1
|
api_version: go1
|
||||||
|
@ -15,7 +15,7 @@ handlers:
|
||||||
script: _go_app
|
script: _go_app
|
||||||
- url: /(|gccgo/)(|commit|packages|result|perf-result|tag|todo|perf|perfdetail|perfgraph|updatebenchmark)
|
- url: /(|gccgo/)(|commit|packages|result|perf-result|tag|todo|perf|perfdetail|perfgraph|updatebenchmark)
|
||||||
script: _go_app
|
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
|
script: _go_app
|
||||||
login: admin
|
login: admin
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ import (
|
||||||
"appengine/datastore"
|
"appengine/datastore"
|
||||||
|
|
||||||
"cache"
|
"cache"
|
||||||
|
|
||||||
|
_ "appengine/remote_api"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -431,7 +431,7 @@ func (a *analysis) genConv(conv *ssa.Convert, cgn *cgnode) {
|
||||||
|
|
||||||
case *types.Pointer:
|
case *types.Pointer:
|
||||||
// *T -> unsafe.Pointer?
|
// *T -> unsafe.Pointer?
|
||||||
if tDst == tUnsafePtr {
|
if tDst.Underlying() == tUnsafePtr {
|
||||||
// ignore for now
|
// ignore for now
|
||||||
// a.copy(res, a.valueNode(conv.X), 1)
|
// a.copy(res, a.valueNode(conv.X), 1)
|
||||||
return
|
return
|
||||||
|
|
|
@ -49,9 +49,17 @@ func conv4() {
|
||||||
print(p) // @pointsto convert@c2p:13
|
print(p) // @pointsto convert@c2p:13
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regression test for b/8231.
|
||||||
|
func conv5() {
|
||||||
|
type P unsafe.Pointer
|
||||||
|
var i *struct{}
|
||||||
|
_ = P(i)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
conv1()
|
conv1()
|
||||||
conv2()
|
conv2()
|
||||||
conv3()
|
conv3()
|
||||||
conv4()
|
conv4()
|
||||||
|
conv5()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ package typeutil
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"unsafe"
|
"reflect"
|
||||||
|
|
||||||
"code.google.com/p/go.tools/go/types"
|
"code.google.com/p/go.tools/go/types"
|
||||||
)
|
)
|
||||||
|
@ -295,7 +295,7 @@ func (h Hasher) hashFor(t types.Type) uint32 {
|
||||||
|
|
||||||
case *types.Named:
|
case *types.Named:
|
||||||
// Not safe with a copying GC; objects may move.
|
// 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:
|
case *types.Tuple:
|
||||||
return h.hashTuple(t)
|
return h.hashTuple(t)
|
||||||
|
|
|
@ -1477,10 +1477,11 @@ func (c *Corpus) UpdateIndex() {
|
||||||
func (c *Corpus) RunIndexer() {
|
func (c *Corpus) RunIndexer() {
|
||||||
// initialize the index from disk if possible
|
// initialize the index from disk if possible
|
||||||
if c.IndexFiles != "" {
|
if c.IndexFiles != "" {
|
||||||
|
c.initFSTree()
|
||||||
if err := c.readIndex(c.IndexFiles); err != nil {
|
if err := c.readIndex(c.IndexFiles); err != nil {
|
||||||
log.Printf("error reading index from file %s: %v", c.IndexFiles, err)
|
log.Printf("error reading index from file %s: %v", c.IndexFiles, err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Repeatedly update the package directory tree and index.
|
// Repeatedly update the package directory tree and index.
|
||||||
|
|
|
@ -254,8 +254,10 @@ func (h *handlerServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
// special cases for top-level package/command directories
|
// special cases for top-level package/command directories
|
||||||
switch tabtitle {
|
switch tabtitle {
|
||||||
case "/src/pkg":
|
case "/src/pkg":
|
||||||
|
title = "Packages"
|
||||||
tabtitle = "Packages"
|
tabtitle = "Packages"
|
||||||
case "/src/cmd":
|
case "/src/cmd":
|
||||||
|
title = "Commands"
|
||||||
tabtitle = "Commands"
|
tabtitle = "Commands"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,10 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<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">
|
<div id="topbar"{{if .Title}} class="wide"{{end}}><div class="container">
|
||||||
|
|
||||||
<form method="GET" action="/search">
|
<form method="GET" action="/search">
|
||||||
|
@ -58,7 +61,6 @@ func main() {
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
{{with .Title}}
|
{{with .Title}}
|
||||||
<div id="plusone"><g:plusone size="small" annotation="none"></g:plusone></div>
|
|
||||||
<h1>{{html .}}</h1>
|
<h1>{{html .}}</h1>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{with .Subtitle}}
|
{{with .Subtitle}}
|
||||||
|
@ -85,11 +87,6 @@ and code is licensed under a <a href="/LICENSE">BSD license</a>.<br>
|
||||||
</div><!-- .container -->
|
</div><!-- .container -->
|
||||||
</div><!-- #page -->
|
</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? -->
|
<!-- 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.js"></script>
|
||||||
<script type="text/javascript" src="/lib/godoc/jquery.treeview.js"></script>
|
<script type="text/javascript" src="/lib/godoc/jquery.treeview.js"></script>
|
||||||
|
|
|
@ -152,7 +152,7 @@ function setupDropdownPlayground() {
|
||||||
'runEl': $('.run', div),
|
'runEl': $('.run', div),
|
||||||
'fmtEl': $('.fmt', div),
|
'fmtEl': $('.fmt', div),
|
||||||
'shareEl': $('.share', div),
|
'shareEl': $('.share', div),
|
||||||
'shareRedirect': 'http://play.golang.org/p/'
|
'shareRedirect': '//play.golang.org/p/'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
|
@ -176,7 +176,7 @@ function setupInlinePlayground() {
|
||||||
'runEl': $('.run', el),
|
'runEl': $('.run', el),
|
||||||
'fmtEl': $('.fmt', el),
|
'fmtEl': $('.fmt', el),
|
||||||
'shareEl': $('.share', el),
|
'shareEl': $('.share', el),
|
||||||
'shareRedirect': 'http://play.golang.org/p/'
|
'shareRedirect': '//play.golang.org/p/'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make the code textarea resize to fit content.
|
// 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() {
|
$(document).ready(function() {
|
||||||
bindSearchEvents();
|
bindSearchEvents();
|
||||||
generateTOC();
|
generateTOC();
|
||||||
|
@ -256,7 +247,6 @@ $(document).ready(function() {
|
||||||
setupTypeInfo();
|
setupTypeInfo();
|
||||||
setupCallgraphs();
|
setupCallgraphs();
|
||||||
toggleHash();
|
toggleHash();
|
||||||
addPlusButtons();
|
|
||||||
|
|
||||||
// godoc.html defines window.initFuncs in the <head> tag, and root.html and
|
// godoc.html defines window.initFuncs in the <head> tag, and root.html and
|
||||||
// codewalk.js push their on-page-ready functions to the list.
|
// codewalk.js push their on-page-ready functions to the list.
|
||||||
|
|
|
@ -237,10 +237,18 @@
|
||||||
{{/* 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="pkg-subdirectories">Subdirectories</h2>
|
<h2 id="pkg-subdirectories">Subdirectories</h2>
|
||||||
{{else}}
|
{{end}}
|
||||||
<div class="pkgGopher">
|
{{if eq $.Dirname "/src/pkg"}}
|
||||||
<img class="gopher" src="/doc/gopher/pkg.png"/>
|
<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>
|
</div>
|
||||||
|
<h2 id="stdlib">Standard library</h2>
|
||||||
|
<img class="gopher" src="/doc/gopher/pkg.png"/>
|
||||||
{{end}}
|
{{end}}
|
||||||
<table class="dir">
|
<table class="dir">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -248,7 +256,7 @@
|
||||||
<th> </th>
|
<th> </th>
|
||||||
<th style="text-align: left; width: auto">Synopsis</th>
|
<th style="text-align: left; width: auto">Synopsis</th>
|
||||||
</tr>
|
</tr>
|
||||||
{{if not $.DirFlat}}
|
{{if not (or (eq $.Dirname "/src/pkg") (eq $.Dirname "/src/cmd") $.DirFlat)}}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="..">..</a></td>
|
<td><a href="..">..</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -271,7 +279,34 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</table>
|
</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}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -411,15 +411,6 @@ img.gopher {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
}
|
}
|
||||||
.pkgGopher {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
.pkgGopher .gopher {
|
|
||||||
float: none;
|
|
||||||
position: relative;
|
|
||||||
top: -40px;
|
|
||||||
margin-bottom: -120px;
|
|
||||||
}
|
|
||||||
h2 { clear: right; }
|
h2 { clear: right; }
|
||||||
|
|
||||||
/* example and drop-down playground */
|
/* example and drop-down playground */
|
||||||
|
@ -601,4 +592,4 @@ a.error {
|
||||||
border-top-left-radius: 4px;
|
border-top-left-radius: 4px;
|
||||||
border-top-right-radius: 4px;
|
border-top-right-radius: 4px;
|
||||||
padding: 2px 4px 2px 4px; /* TRBL */
|
padding: 2px 4px 2px 4px; /* TRBL */
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,6 +238,8 @@ func parseArgs(name string, line int, args []string) (res []interface{}, err err
|
||||||
res[i] = v
|
res[i] = v
|
||||||
case '$':
|
case '$':
|
||||||
res[i] = "$"
|
res[i] = "$"
|
||||||
|
case '_':
|
||||||
|
// Do nothing; '_' indicates an intentionally empty parameter.
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("%s:%d bad code argument %q", name, line, v)
|
return nil, fmt.Errorf("%s:%d bad code argument %q", name, line, v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 syntax is simple: 1 or 3 space-separated arguments.
|
||||||
The first argument is always the file name.
|
The first argument is always the file name.
|
||||||
If there are more arguments, they are the height and width;
|
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/betsy.jpg 100 200
|
||||||
|
|
||||||
|
.image images/janet.jpg _ 300
|
||||||
|
|
||||||
iframe:
|
iframe:
|
||||||
|
|
||||||
The function "iframe" injects iframes (pages inside pages).
|
The function "iframe" injects iframes (pages inside pages).
|
||||||
|
|
|
@ -32,6 +32,11 @@ func parseImage(ctx *Context, fileName string, lineno int, text string) (Elem, e
|
||||||
case 0:
|
case 0:
|
||||||
// no size parameters
|
// no size parameters
|
||||||
case 2:
|
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 {
|
if v, ok := a[0].(int); ok {
|
||||||
img.Height = v
|
img.Height = v
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue