From a5cddac55492d4b6ca4c7ab97cd5f0383f4bb31a Mon Sep 17 00:00:00 2001 From: Vladimir Alaev Date: Wed, 4 Oct 2017 16:54:05 +0300 Subject: [PATCH] Fix docs generator to ignore all child folders of the vendor folder within project dir --- generate/swaggergen/g_docs.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 642c263..1d758db 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -105,11 +105,12 @@ func ParsePackagesFromDir(dirpath string) { return nil } - // 7 is length of 'vendor' (6) + length of file path separator (1) - // so we skip dir 'vendor' which is directly under dirpath - if !(len(fpath) == len(dirpath)+7 && strings.HasSuffix(fpath, "vendor")) && + // skip folder if it's a 'vendor' folder within dirpath or its child, + // all 'tests' folders and dot folders wihin dirpath + d, _ := filepath.Rel(dirpath, fpath) + if !(d == "vendor" || strings.HasPrefix(d, "vendor"+string(os.PathSeparator))) && !strings.Contains(fpath, "tests") && - !(len(fpath) > len(dirpath) && fpath[len(dirpath)+1] == '.') { + !(d[0] == '.') { err = parsePackageFromDir(fpath) if err != nil { // Send the error to through the channel and continue walking