github.com/ahmet2mir/goreleaser@v0.180.3-0.20210927151101-8e5ee5a9b8c5/cmd/docs.go (about)

     1  package cmd
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/spf13/cobra"
     7  	"github.com/spf13/cobra/doc"
     8  )
     9  
    10  type docsCmd struct {
    11  	cmd *cobra.Command
    12  }
    13  
    14  func newDocsCmd() *docsCmd {
    15  	root := &docsCmd{}
    16  	cmd := &cobra.Command{
    17  		Use:                   "docs",
    18  		Short:                 "Generates GoReleaser's command line docs",
    19  		SilenceUsage:          true,
    20  		DisableFlagsInUseLine: true,
    21  		Hidden:                true,
    22  		Args:                  cobra.NoArgs,
    23  		RunE: func(cmd *cobra.Command, args []string) error {
    24  			root.cmd.Root().DisableAutoGenTag = true
    25  			return doc.GenMarkdownTreeCustom(root.cmd.Root(), "www/docs/cmd", func(_ string) string {
    26  				return ""
    27  			}, func(s string) string {
    28  				return "/cmd/" + strings.TrimSuffix(s, ".md") + "/"
    29  			})
    30  		},
    31  	}
    32  
    33  	root.cmd = cmd
    34  	return root
    35  }