mirror of
https://github.com/beego/bee.git
synced 2024-12-26 01:10:50 +00:00
fix the generate docs when route has system packages
This commit is contained in:
parent
531ce3010d
commit
61e13f70be
16
g_docs.go
16
g_docs.go
@ -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{}
|
||||
|
Loading…
Reference in New Issue
Block a user