GenMarkdownTreeCustom is the same as GenMarkdownTree, but with custom filePrepender and linkHandler.
(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string)
| 178 | // GenMarkdownTreeCustom is the same as GenMarkdownTree, but |
| 179 | // with custom filePrepender and linkHandler. |
| 180 | func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error { |
| 181 | if os.Getenv("GH_COBRA") != "" { |
| 182 | return doc.GenMarkdownTreeCustom(cmd, dir, filePrepender, linkHandler) |
| 183 | } |
| 184 | |
| 185 | for _, c := range cmd.Commands() { |
| 186 | _, forceGeneration := c.Annotations["markdown:generate"] |
| 187 | if c.Hidden && !forceGeneration { |
| 188 | continue |
| 189 | } |
| 190 | |
| 191 | if err := GenMarkdownTreeCustom(c, dir, filePrepender, linkHandler); err != nil { |
| 192 | return err |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | filename := filepath.Join(dir, cmdManualPath(cmd)) |
| 197 | f, err := os.Create(filename) |
| 198 | if err != nil { |
| 199 | return err |
| 200 | } |
| 201 | defer f.Close() |
| 202 | |
| 203 | if _, err := io.WriteString(f, filePrepender(filename)); err != nil { |
| 204 | return err |
| 205 | } |
| 206 | if err := genMarkdownCustom(cmd, f, linkHandler); err != nil { |
| 207 | return err |
| 208 | } |
| 209 | return nil |
| 210 | } |
| 211 | |
| 212 | func cmdManualPath(c *cobra.Command) string { |
| 213 | if basenameOverride, found := c.Annotations["markdown:basename"]; found { |