Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

生成文档问题 #825

Open
v3vip opened this issue Jun 11, 2022 · 0 comments
Open

生成文档问题 #825

v3vip opened this issue Jun 11, 2022 · 0 comments

Comments

@v3vip
Copy link

v3vip commented Jun 11, 2022

有时项目需要一些公共库给不同的项目使用, 如Models,但是如果这些公共库,不在当前项目的目录下时,生成文档时,会报Cannot find the object错误,生成的文档也找不到有关Models的说明。所以我对cmd\commands\generate\generate.go 文件里的GenerateCode方法做了处理。
代码示例:
case "docs":
f, err := os.Open(currpath + "\docs.conf")
if err == nil {
rd := bufio.NewReader(f)
for {
line, err := rd.ReadString('\n')
line = strings.Trim(line, " \r\n")
if len(line) > 0 {
swaggergen.GenerateDocs(currpath + "\" + line)
}
if err != nil || err == io.EOF {
break
}
}
f.Close()
}
swaggergen.GenerateDocs(currpath)
这样处理后,只需在当前项目的根目录下加上docs.conf文件,在里面按行指定相对路径就可以生成Models的说明了。
docs.conf内容示例:
../xmodels
../xutils

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant