Added command to generate the documentation

pull/4840/head
Jituri, Pranav 2019-07-23 01:31:41 +05:30
parent bcf3597851
commit f97451e0f2
1 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,39 @@
package cmd
import (
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/out"
"os"
)
var path string
// generateDocs represents the generate-docs command
var generateDocs = &cobra.Command{
Use: "generate-docs",
Short: "Populates the specified folder with documentation in markdown about minikube",
Long: "Populates the specified folder with documentation in markdown about minikube",
Example: "minikube generate-docs --path <FOLDER_PATH>",
Run: func(cmd *cobra.Command, args []string) {
// if directory does not exist
docsPath, err := os.Stat(path)
if err != nil || !docsPath.IsDir() {
exit.UsageT("Unable to generate the documentation. Please ensure that the path specified is a directory, exists & you have permission to write to it.")
}
// generate docs
if err := doc.GenMarkdownTree(RootCmd,path); err != nil {
exit.WithError("Unable to generate docs", err)
}
out.T(out.Documentation,"Docs have been saved at - {{.path}}",out.V{"path":path})
},
}
func init() {
generateDocs.Flags().StringVar(&path,"path","","The path on the file system where the docs in markdown need to be saved")
RootCmd.AddCommand(generateDocs)
}