1
0
mirror of https://github.com/beego/bee.git synced 2024-11-25 04:40:54 +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" "path/filepath"
"reflect" "reflect"
"regexp" "regexp"
"runtime"
"strconv" "strconv"
"strings" "strings"
"unicode" "unicode"
@ -255,6 +256,9 @@ func analisysNSInclude(baseurl string, ce *ast.CallExpr) string {
func analisyscontrollerPkg(pkgpath string) { func analisyscontrollerPkg(pkgpath string) {
pkgpath = strings.Trim(pkgpath, "\"") pkgpath = strings.Trim(pkgpath, "\"")
if isSystemPackage(pkgpath) {
return
}
pps := strings.Split(pkgpath, "/") pps := strings.Split(pkgpath, "/")
importlist[pps[len(pps)-1]] = pkgpath importlist[pps[len(pps)-1]] = pkgpath
if pkgpath == "github.com/astaxie/beego" { 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 // parse the func comments
func parserComments(comments *ast.CommentGroup, funcName, controllerName, pkgpath string) error { func parserComments(comments *ast.CommentGroup, funcName, controllerName, pkgpath string) error {
innerapi := swagger.Api{} innerapi := swagger.Api{}