Make markdown:generate annotation a markdown generation override for hidden commands
This commit is contained in:
parent
f770c6481c
commit
241e90aa9b
5 changed files with 6 additions and 18 deletions
|
|
@ -82,10 +82,9 @@ func GenMarkdownTree(cmd *cobra.Command, dir string) error {
|
||||||
// with custom filePrepender and linkHandler.
|
// with custom filePrepender and linkHandler.
|
||||||
func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error {
|
func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHandler func(string) string) error {
|
||||||
for _, c := range cmd.Commands() {
|
for _, c := range cmd.Commands() {
|
||||||
if genMarkdown, ok := c.Annotations["markdown:generate"]; ok {
|
_, forceGeneration := c.Annotations["markdown:generate"]
|
||||||
if genMarkdown == "false" {
|
if c.Hidden && !forceGeneration {
|
||||||
continue
|
continue
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := GenMarkdownTreeCustom(c, dir, filePrepender, linkHandler); err != nil {
|
if err := GenMarkdownTreeCustom(c, dir, filePrepender, linkHandler); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,10 @@ func NewCmdCredits(f *cmdutil.Factory, runF func(*CreditsOptions) error) *cobra.
|
||||||
Example: heredoc.Doc(`
|
Example: heredoc.Doc(`
|
||||||
# see a credits animation for this project
|
# see a credits animation for this project
|
||||||
$ gh credits
|
$ gh credits
|
||||||
|
|
||||||
# display a non-animated thank you
|
# display a non-animated thank you
|
||||||
$ gh credits -s
|
$ gh credits -s
|
||||||
|
|
||||||
# just print the contributors, one per line
|
# just print the contributors, one per line
|
||||||
$ gh credits | cat
|
$ gh credits | cat
|
||||||
`),
|
`),
|
||||||
|
|
@ -61,9 +61,6 @@ func NewCmdCredits(f *cmdutil.Factory, runF func(*CreditsOptions) error) *cobra.
|
||||||
return creditsRun(opts)
|
return creditsRun(opts)
|
||||||
},
|
},
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
Annotations: map[string]string{
|
|
||||||
"markdown:generate": "false",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().BoolVarP(&opts.Static, "static", "s", false, "Print a static version of the credits")
|
cmd.Flags().BoolVarP(&opts.Static, "static", "s", false, "Print a static version of the credits")
|
||||||
|
|
@ -107,9 +104,6 @@ func NewCmdRepoCredits(f *cmdutil.Factory, runF func(*CreditsOptions) error) *co
|
||||||
return creditsRun(opts)
|
return creditsRun(opts)
|
||||||
},
|
},
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
Annotations: map[string]string{
|
|
||||||
"markdown:generate": "false",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().BoolVarP(&opts.Static, "static", "s", false, "Print a static version of the credits")
|
cmd.Flags().BoolVarP(&opts.Static, "static", "s", false, "Print a static version of the credits")
|
||||||
|
|
|
||||||
|
|
@ -115,9 +115,6 @@ func NewCmdGarden(f *cmdutil.Factory, runF func(*GardenOptions) error) *cobra.Co
|
||||||
}
|
}
|
||||||
return gardenRun(&opts)
|
return gardenRun(&opts)
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
|
||||||
"markdown:generate": "false",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ func NewHelpTopic(topic string) *cobra.Command {
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
Run: helpTopicHelpFunc,
|
Run: helpTopicHelpFunc,
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
|
"markdown:generate": "true",
|
||||||
"markdown:basename": "gh_help_" + topic,
|
"markdown:basename": "gh_help_" + topic,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,6 @@ func NewCmdVersion(f *cmdutil.Factory, version, buildDate string) *cobra.Command
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
fmt.Fprint(f.IOStreams.Out, Format(version, buildDate))
|
fmt.Fprint(f.IOStreams.Out, Format(version, buildDate))
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{
|
|
||||||
"markdown:generate": "false",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdutil.DisableAuthCheck(cmd)
|
cmdutil.DisableAuthCheck(cmd)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue