mirror of
https://github.com/beego/bee.git
synced 2024-11-24 18:30:53 +00:00
Fixes #401
Consider vendor folder when analyzing router.go parsed imports.
This commit is contained in:
parent
52a37a86a9
commit
1336d6b411
@ -194,7 +194,7 @@ func GenerateDocs(curpath string) {
|
|||||||
if im.Name != nil {
|
if im.Name != nil {
|
||||||
localName = im.Name.Name
|
localName = im.Name.Name
|
||||||
}
|
}
|
||||||
analyseControllerPkg(localName, im.Path.Value)
|
analyseControllerPkg(path.Join(curpath, "vendor"), localName, im.Path.Value)
|
||||||
}
|
}
|
||||||
for _, d := range f.Decls {
|
for _, d := range f.Decls {
|
||||||
switch specDecl := d.(type) {
|
switch specDecl := d.(type) {
|
||||||
@ -336,7 +336,7 @@ func analyseNSInclude(baseurl string, ce *ast.CallExpr) string {
|
|||||||
return cname
|
return cname
|
||||||
}
|
}
|
||||||
|
|
||||||
func analyseControllerPkg(localName, pkgpath string) {
|
func analyseControllerPkg(vendorPath, localName, pkgpath string) {
|
||||||
pkgpath = strings.Trim(pkgpath, "\"")
|
pkgpath = strings.Trim(pkgpath, "\"")
|
||||||
if isSystemPackage(pkgpath) {
|
if isSystemPackage(pkgpath) {
|
||||||
return
|
return
|
||||||
@ -356,6 +356,10 @@ func analyseControllerPkg(localName, pkgpath string) {
|
|||||||
}
|
}
|
||||||
pkgRealpath := ""
|
pkgRealpath := ""
|
||||||
|
|
||||||
|
wg, _ := filepath.EvalSymlinks(filepath.Join(vendorPath, pkgpath))
|
||||||
|
if utils.FileExists(wg) {
|
||||||
|
pkgRealpath = wg
|
||||||
|
} else {
|
||||||
wgopath := filepath.SplitList(gopath)
|
wgopath := filepath.SplitList(gopath)
|
||||||
for _, wg := range wgopath {
|
for _, wg := range wgopath {
|
||||||
wg, _ = filepath.EvalSymlinks(filepath.Join(wg, "src", pkgpath))
|
wg, _ = filepath.EvalSymlinks(filepath.Join(wg, "src", pkgpath))
|
||||||
@ -364,13 +368,14 @@ func analyseControllerPkg(localName, pkgpath string) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if pkgRealpath != "" {
|
if pkgRealpath != "" {
|
||||||
if _, ok := pkgCache[pkgpath]; ok {
|
if _, ok := pkgCache[pkgpath]; ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pkgCache[pkgpath] = struct{}{}
|
pkgCache[pkgpath] = struct{}{}
|
||||||
} else {
|
} else {
|
||||||
beeLogger.Log.Fatalf("Package '%s' does not exist in the GOPATH", pkgpath)
|
beeLogger.Log.Fatalf("Package '%s' does not exist in the GOPATH or vendor path", pkgpath)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSet := token.NewFileSet()
|
fileSet := token.NewFileSet()
|
||||||
|
Loading…
Reference in New Issue
Block a user