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