GenMarkdownTreeCustom is the same as GenMarkdownTree, but with custom filePrepender and linkHandler.
(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string)
| 131 | // GenMarkdownTreeCustom is the same as GenMarkdownTree, but |
| 132 | // with custom filePrepender and linkHandler. |
| 133 | func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error { |
| 134 | for _, c := range cmd.Commands() { |
| 135 | if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() { |
| 136 | continue |
| 137 | } |
| 138 | if err := GenMarkdownTreeCustom(c, dir, filePrepender, linkHandler); err != nil { |
| 139 | return err |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | basename := strings.ReplaceAll(cmd.CommandPath(), " ", "_") + markdownExtension |
| 144 | filename := filepath.Join(dir, basename) |
| 145 | f, err := os.Create(filename) |
| 146 | if err != nil { |
| 147 | return err |
| 148 | } |
| 149 | defer f.Close() |
| 150 | |
| 151 | if _, err := io.WriteString(f, filePrepender(filename)); err != nil { |
| 152 | return err |
| 153 | } |
| 154 | if err := GenMarkdownCustom(cmd, f, linkHandler); err != nil { |
| 155 | return err |
| 156 | } |
| 157 | return nil |
| 158 | } |
no test coverage detected