Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CobraDocsCmd = &cobra.Command{ Use: "docs", Short: "Generate docs", Long: `Generate documentation markdown files from the source code.`, Hidden: true, Run: func(cmd *cobra.Command, args []string) { outputDir, _ := cmd.Flags().GetString("output-dir") identity := func(s string) string { return s } emptyStr := func(s string) string { isRootCommand := strings.HasSuffix(s, fmt.Sprintf("%c_index.md", os.PathSeparator)) titleCaser := cases.Title(language.English) title := strings.TrimSuffix(strings.ReplaceAll(filepath.Base(s), "_", " "), markdownExtension) var prepend string if isRootCommand { commandNameTitle := titleCaser.String(cmd.Root().Name()) prepend = fmt.Sprintf("---\ntitle: %s CLI\ndescription: %s CLI Reference\nno_list: true\nweight: 1\n---\n", commandNameTitle, commandNameTitle) } else { title = strings.TrimSpace(strings.TrimPrefix(title, cmd.Root().Name())) args := strings.Split(title, " ") currentCmd, _, err := cmd.Root().Find(args) if err != nil { fmt.Println("error getting command", err) } title = titleCaser.String(title) prepend = fmt.Sprintf("---\ntitle: %s\ndescription: %s\n---\n\n", title, currentCmd.Short) } return prepend } err := GenMarkdownTreeCustom(cmd.Root(), outputDir, emptyStr, identity) if err != nil { fmt.Printf("error generating docs err=%s", err) } }, }
CobraDocsCmd represents the docs command
Functions ¶
func GenMarkdownCustom ¶ added in v1.0.1
GenMarkdownCustom creates custom markdown output.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.