1
0
mirror of https://github.com/golang/go synced 2024-11-13 17:10:21 -07:00

godoc: use virtual file system when generating package synopses

Fix for godoc on app engine.

R=dsymonds
CC=golang-dev
https://golang.org/cl/4922050
This commit is contained in:
Robert Griesemer 2011-08-24 09:52:16 -07:00
parent 940281bd3c
commit 52818f4583
2 changed files with 10 additions and 10 deletions

View File

@ -117,7 +117,7 @@ func (b *treeBuilder) newDirTree(fset *token.FileSet, path, name string, depth i
// though the directory doesn't contain any real package files - was bug)
if synopses[0] == "" {
// no "optimal" package synopsis yet; continue to collect synopses
file, err := parser.ParseFile(fset, filepath.Join(path, d.Name()), nil,
file, err := parseFile(fset, filepath.Join(path, d.Name()),
parser.ParseComments|parser.PackageClauseOnly)
if err == nil {
hasPkgFiles = true

View File

@ -17,18 +17,18 @@ import (
"path/filepath"
)
func parseFile(fset *token.FileSet, filename string, mode uint) (*ast.File, os.Error) {
src, err := fs.ReadFile(filename)
if err != nil {
return nil, err
}
return parser.ParseFile(fset, filename, src, mode)
}
func parseFiles(fset *token.FileSet, filenames []string) (pkgs map[string]*ast.Package, first os.Error) {
pkgs = make(map[string]*ast.Package)
for _, filename := range filenames {
src, err := fs.ReadFile(filename)
if err != nil {
if first == nil {
first = err
}
continue
}
file, err := parser.ParseFile(fset, filename, src, parser.ParseComments)
file, err := parseFile(fset, filename, parser.ParseComments)
if err != nil {
if first == nil {
first = err