-
Notifications
You must be signed in to change notification settings - Fork 338
/
docs.go
43 lines (38 loc) · 1.25 KB
/
docs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*----------------------------------------------------------------
* Copyright (c) ThoughtWorks, Inc.
* Licensed under the Apache License, Version 2.0
* See LICENSE in the project root for license information.
*----------------------------------------------------------------*/
package cmd
import (
"fmt"
"github.com/getgauge/gauge/api"
"github.com/getgauge/gauge/config"
"github.com/getgauge/gauge/plugin"
"github.com/spf13/cobra"
)
var docsCmd = &cobra.Command{
Use: "docs [flags] <plugin> [args]",
Short: "Generate documentation using specified plugin",
Long: `Generate documentation using specified plugin.`,
Example: " gauge docs spectacle specs/",
Run: func(cmd *cobra.Command, args []string) {
if err := config.SetProjectRoot(args); err != nil {
exit(err, cmd.UsageString())
}
loadEnvAndReinitLogger(cmd)
if len(args) < 1 {
exit(fmt.Errorf("Missing argument <plugin name>."), cmd.UsageString())
}
specDirs := getSpecsDir(args[1:])
var startAPIFunc = func(specDirs []string) int {
gaugeConnectionHandler := api.Start(specDirs)
return gaugeConnectionHandler.ConnectionPortNumber()
}
plugin.GenerateDoc(args[0], specDirs, startAPIFunc)
},
DisableAutoGenTag: true,
}
func init() {
GaugeCmd.AddCommand(docsCmd)
}