mirror of
https://github.com/golang/go
synced 2024-11-22 04:14:42 -07:00
gobuilder: ignore _test.go files when looking for docs, more logging
R=n13m3y3r CC=golang-dev https://golang.org/cl/4918050
This commit is contained in:
parent
1f523e2579
commit
4e7250db12
@ -5,6 +5,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"go/doc"
|
"go/doc"
|
||||||
"go/parser"
|
"go/parser"
|
||||||
"go/token"
|
"go/token"
|
||||||
@ -17,6 +18,10 @@ import (
|
|||||||
const MaxCommentLength = 500 // App Engine won't store more in a StringProperty.
|
const MaxCommentLength = 500 // App Engine won't store more in a StringProperty.
|
||||||
|
|
||||||
func (b *Builder) buildPackages(workpath string, hash string) os.Error {
|
func (b *Builder) buildPackages(workpath string, hash string) os.Error {
|
||||||
|
logdir := filepath.Join(*buildroot, "log")
|
||||||
|
if err := os.Mkdir(logdir, 0755); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
pkgs, err := packages()
|
pkgs, err := packages()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -44,9 +49,13 @@ func (b *Builder) buildPackages(workpath string, hash string) os.Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get doc comment from package source
|
// get doc comment from package source
|
||||||
info, err := packageComment(p, filepath.Join(goroot, "src", "pkg", p))
|
var info string
|
||||||
if err != nil {
|
pkgPath := filepath.Join(goroot, "src", "pkg", p)
|
||||||
log.Printf("packageComment %v: %v", p, err)
|
if _, err := os.Stat(pkgPath); err == nil {
|
||||||
|
info, err = packageComment(p, pkgPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("packageComment %v: %v", p, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update dashboard with build state + info
|
// update dashboard with build state + info
|
||||||
@ -54,6 +63,19 @@ func (b *Builder) buildPackages(workpath string, hash string) os.Error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("updatePackage %v: %v", p, err)
|
log.Printf("updatePackage %v: %v", p, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if code == 0 {
|
||||||
|
log.Println("Build succeeded:", p)
|
||||||
|
} else {
|
||||||
|
log.Println("Build failed:", p)
|
||||||
|
fn := filepath.Join(logdir, strings.Replace(p, "/", "_", -1))
|
||||||
|
if f, err := os.Create(fn); err != nil {
|
||||||
|
log.Printf("creating %s: %v", fn, err)
|
||||||
|
} else {
|
||||||
|
fmt.Fprint(f, buildLog)
|
||||||
|
f.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -61,6 +83,7 @@ func (b *Builder) buildPackages(workpath string, hash string) os.Error {
|
|||||||
func isGoFile(fi *os.FileInfo) bool {
|
func isGoFile(fi *os.FileInfo) bool {
|
||||||
return fi.IsRegular() && // exclude directories
|
return fi.IsRegular() && // exclude directories
|
||||||
!strings.HasPrefix(fi.Name, ".") && // ignore .files
|
!strings.HasPrefix(fi.Name, ".") && // ignore .files
|
||||||
|
!strings.HasSuffix(fi.Name, "_test.go") && // ignore tests
|
||||||
filepath.Ext(fi.Name) == ".go"
|
filepath.Ext(fi.Name) == ".go"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,10 +97,13 @@ func packageComment(pkg, pkgpath string) (info string, err os.Error) {
|
|||||||
if name == "main" {
|
if name == "main" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if info != "" {
|
|
||||||
return "", os.NewError("multiple non-main package docs")
|
|
||||||
}
|
|
||||||
pdoc := doc.NewPackageDoc(pkgs[name], pkg)
|
pdoc := doc.NewPackageDoc(pkgs[name], pkg)
|
||||||
|
if pdoc.Doc == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if info != "" {
|
||||||
|
return "", os.NewError("multiple packages with docs")
|
||||||
|
}
|
||||||
info = pdoc.Doc
|
info = pdoc.Doc
|
||||||
}
|
}
|
||||||
// grab only first paragraph
|
// grab only first paragraph
|
||||||
|
Loading…
Reference in New Issue
Block a user