Generate route with prefix (#1200)

* Generate route with prefix

* Update api convert

* Remove TrimSpace

* Update path join

* Format code

* Format code

Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
anqiansong
2021-11-03 20:57:03 +08:00
committed by GitHub
parent 6aba5f74fc
commit 01786c5e63
8 changed files with 43 additions and 7 deletions

View File

@@ -42,14 +42,15 @@ func DocCommand(c *cli.Context) error {
return err
}
for _, path := range files {
api, err := parser.Parse(path)
for _, p := range files {
api, err := parser.Parse(p)
if err != nil {
return fmt.Errorf("parse file: %s, err: %s", path, err.Error())
return fmt.Errorf("parse file: %s, err: %s", p, err.Error())
}
err = genDoc(api, filepath.Dir(filepath.Join(outputDir, path[len(dir):])),
strings.Replace(path[len(filepath.Dir(path)):], ".api", ".md", 1))
api.Service = api.Service.JoinPrefix()
err = genDoc(api, filepath.Dir(filepath.Join(outputDir, p[len(dir):])),
strings.Replace(p[len(filepath.Dir(p)):], ".api", ".md", 1))
if err != nil {
return err
}