mirror of https://github.com/spf13/cobra.git
fix inconsistencies in md generation
This commit is contained in:
parent
95d8a1e45d
commit
5d16684e88
|
@ -31,7 +31,7 @@ func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) error {
|
||||||
flags := cmd.NonInheritedFlags()
|
flags := cmd.NonInheritedFlags()
|
||||||
flags.SetOutput(buf)
|
flags.SetOutput(buf)
|
||||||
if flags.HasAvailableFlags() {
|
if flags.HasAvailableFlags() {
|
||||||
buf.WriteString("### Options\n\n```\n")
|
buf.WriteString("### Flags\n\n```\n")
|
||||||
flags.PrintDefaults()
|
flags.PrintDefaults()
|
||||||
buf.WriteString("```\n\n")
|
buf.WriteString("```\n\n")
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) error {
|
||||||
parentFlags := cmd.InheritedFlags()
|
parentFlags := cmd.InheritedFlags()
|
||||||
parentFlags.SetOutput(buf)
|
parentFlags.SetOutput(buf)
|
||||||
if parentFlags.HasAvailableFlags() {
|
if parentFlags.HasAvailableFlags() {
|
||||||
buf.WriteString("### Options inherited from parent commands\n\n```\n")
|
buf.WriteString("### Flags inherited from parent commands\n\n```\n")
|
||||||
parentFlags.PrintDefaults()
|
parentFlags.PrintDefaults()
|
||||||
buf.WriteString("```\n\n")
|
buf.WriteString("```\n\n")
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ func TestGenMdDoc(t *testing.T) {
|
||||||
checkStringContains(t, output, rootCmd.Short)
|
checkStringContains(t, output, rootCmd.Short)
|
||||||
checkStringContains(t, output, echoSubCmd.Short)
|
checkStringContains(t, output, echoSubCmd.Short)
|
||||||
checkStringOmits(t, output, deprecatedCmd.Short)
|
checkStringOmits(t, output, deprecatedCmd.Short)
|
||||||
checkStringContains(t, output, "Options inherited from parent commands")
|
checkStringContains(t, output, "Flags inherited from parent commands")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGenMdDocWithNoLongOrSynopsis(t *testing.T) {
|
func TestGenMdDocWithNoLongOrSynopsis(t *testing.T) {
|
||||||
|
@ -52,7 +52,7 @@ func TestGenMdDocWithNoLongOrSynopsis(t *testing.T) {
|
||||||
|
|
||||||
checkStringContains(t, output, dummyCmd.Example)
|
checkStringContains(t, output, dummyCmd.Example)
|
||||||
checkStringContains(t, output, dummyCmd.Short)
|
checkStringContains(t, output, dummyCmd.Short)
|
||||||
checkStringContains(t, output, "Options inherited from parent commands")
|
checkStringContains(t, output, "Flags inherited from parent commands")
|
||||||
checkStringOmits(t, output, "### Synopsis")
|
checkStringOmits(t, output, "### Synopsis")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ func TestGenMdNoHiddenParents(t *testing.T) {
|
||||||
checkStringContains(t, output, rootCmd.Short)
|
checkStringContains(t, output, rootCmd.Short)
|
||||||
checkStringContains(t, output, echoSubCmd.Short)
|
checkStringContains(t, output, echoSubCmd.Short)
|
||||||
checkStringOmits(t, output, deprecatedCmd.Short)
|
checkStringOmits(t, output, deprecatedCmd.Short)
|
||||||
checkStringOmits(t, output, "Options inherited from parent commands")
|
checkStringOmits(t, output, "Flags inherited from parent commands")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGenMdNoTag(t *testing.T) {
|
func TestGenMdNoTag(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue