diff options
author | Robert Griesemer <gri@golang.org> | 2009-12-15 15:33:31 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2009-12-15 15:33:31 -0800 |
commit | d9527dd16f72598b54a64550607bf892efa12384 (patch) | |
tree | 2ad16a7db2d3c484b47426ad2568359ab633820c /src/cmd/godoc/snippet.go | |
parent | aea97e0bd7da9cef1cc631ddbd3578a0877a4fcc (diff) | |
download | golang-d9527dd16f72598b54a64550607bf892efa12384.tar.gz |
1) Change default gofmt default settings for
parsing and printing to new syntax.
Use -oldparser to parse the old syntax,
use -oldprinter to print the old syntax.
2) Change default gofmt formatting settings
to use tabs for indentation only and to use
spaces for alignment. This will make the code
alignment insensitive to an editor's tabwidth.
Use -spaces=false to use tabs for alignment.
3) Manually changed src/exp/parser/parser_test.go
so that it doesn't try to parse the parser's
source files using the old syntax (they have
new syntax now).
4) gofmt -w src misc test/bench
1st set of files.
R=rsc
CC=agl, golang-dev, iant, ken2, r
http://codereview.appspot.com/180047
Diffstat (limited to 'src/cmd/godoc/snippet.go')
-rwxr-xr-x | src/cmd/godoc/snippet.go | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/cmd/godoc/snippet.go b/src/cmd/godoc/snippet.go index be027ffc8..98bc97285 100755 --- a/src/cmd/godoc/snippet.go +++ b/src/cmd/godoc/snippet.go @@ -10,44 +10,44 @@ package main import ( - "bytes"; - "go/ast"; - "go/printer"; - "fmt"; - "strings"; + "bytes" + "go/ast" + "go/printer" + "fmt" + "strings" ) type Snippet struct { - Line int; - Text string; + Line int + Text string } type snippetStyler struct { - Styler; // defined in godoc.go - highlight *ast.Ident; // identifier to highlight + Styler // defined in godoc.go + highlight *ast.Ident // identifier to highlight } func (s *snippetStyler) LineTag(line int) (text []uint8, tag printer.HTMLTag) { - return // no LineTag for snippets + return // no LineTag for snippets } func (s *snippetStyler) Ident(id *ast.Ident) (text []byte, tag printer.HTMLTag) { - text = strings.Bytes(id.Value); + text = strings.Bytes(id.Value) if s.highlight == id { tag = printer.HTMLTag{"<span class=highlight>", "</span>"} } - return; + return } func newSnippet(decl ast.Decl, id *ast.Ident) *Snippet { - var buf bytes.Buffer; - writeNode(&buf, decl, true, &snippetStyler{highlight: id}); - return &Snippet{id.Pos().Line, buf.String()}; + var buf bytes.Buffer + writeNode(&buf, decl, true, &snippetStyler{highlight: id}) + return &Snippet{id.Pos().Line, buf.String()} } @@ -70,32 +70,32 @@ func findSpec(list []ast.Spec, id *ast.Ident) ast.Spec { } } } - return nil; + return nil } func genSnippet(d *ast.GenDecl, id *ast.Ident) *Snippet { - s := findSpec(d.Specs, id); + s := findSpec(d.Specs, id) if s == nil { - return nil // declaration doesn't contain id - exit gracefully + return nil // declaration doesn't contain id - exit gracefully } // only use the spec containing the id for the snippet - dd := &ast.GenDecl{d.Doc, d.Position, d.Tok, d.Lparen, []ast.Spec{s}, d.Rparen}; + dd := &ast.GenDecl{d.Doc, d.Position, d.Tok, d.Lparen, []ast.Spec{s}, d.Rparen} - return newSnippet(dd, id); + return newSnippet(dd, id) } func funcSnippet(d *ast.FuncDecl, id *ast.Ident) *Snippet { if d.Name != id { - return nil // declaration doesn't contain id - exit gracefully + return nil // declaration doesn't contain id - exit gracefully } // only use the function signature for the snippet - dd := &ast.FuncDecl{d.Doc, d.Recv, d.Name, d.Type, nil}; + dd := &ast.FuncDecl{d.Doc, d.Recv, d.Name, d.Type, nil} - return newSnippet(dd, id); + return newSnippet(dd, id) } @@ -118,5 +118,5 @@ func NewSnippet(decl ast.Decl, id *ast.Ident) (s *Snippet) { fmt.Sprintf(`could not generate a snippet for <span class="highlight">%s</span>`, id.Value), } } - return; + return } |