MCPcopy
hub / github.com/cli/cli / GenMarkdownTreeCustom

Function GenMarkdownTreeCustom

internal/docs/markdown.go:180–210  ·  view source on GitHub ↗

GenMarkdownTreeCustom is the same as GenMarkdownTree, but with custom filePrepender and linkHandler.

(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string)

Source from the content-addressed store, hash-verified

178// GenMarkdownTreeCustom is the same as GenMarkdownTree, but
179// with custom filePrepender and linkHandler.
180func 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
212func cmdManualPath(c *cobra.Command) string {
213 if basenameOverride, found := c.Annotations["markdown:basename"]; found {

Callers 2

runFunction · 0.92
TestGenMdTreeFunction · 0.85

Calls 6

cmdManualPathFunction · 0.85
filePrependerFunction · 0.85
genMarkdownCustomFunction · 0.85
JoinMethod · 0.80
CreateMethod · 0.65
CloseMethod · 0.65

Tested by 1

TestGenMdTreeFunction · 0.68