1
0
mirror of https://github.com/beego/bee.git synced 2024-11-24 23:30:55 +00:00

fix the generate docs when route has system packages

This commit is contained in:
astaxie 2014-09-04 22:35:30 +08:00
parent 531ce3010d
commit 61e13f70be

View File

@ -26,6 +26,7 @@ import (
"path/filepath"
"reflect"
"regexp"
"runtime"
"strconv"
"strings"
"unicode"
@ -255,6 +256,9 @@ func analisysNSInclude(baseurl string, ce *ast.CallExpr) string {
func analisyscontrollerPkg(pkgpath string) {
pkgpath = strings.Trim(pkgpath, "\"")
if isSystemPackage(pkgpath) {
return
}
pps := strings.Split(pkgpath, "/")
importlist[pps[len(pps)-1]] = pkgpath
if pkgpath == "github.com/astaxie/beego" {
@ -318,6 +322,18 @@ func analisyscontrollerPkg(pkgpath string) {
}
}
func isSystemPackage(pkgpath string) bool {
goroot := runtime.GOROOT()
if goroot == "" {
panic("goroot is empty, do you install Go right?")
}
wg, _ := filepath.EvalSymlinks(filepath.Join(goroot, "src", "pkg", pkgpath))
if utils.FileExists(wg) {
return true
}
return false
}
// parse the func comments
func parserComments(comments *ast.CommentGroup, funcName, controllerName, pkgpath string) error {
innerapi := swagger.Api{}