Use the 'example' section of cobra commands

This makes examples their own section in the docs, if they are defined.
This commit is contained in:
Eric Paris
2015-02-20 16:27:56 -05:00
parent c2c86b0a6d
commit 781ca91a59
2 changed files with 15 additions and 4 deletions

View File

@@ -133,6 +133,11 @@ func genMarkdown(command *cobra.Command, parent, docsDir string) {
preamble(out, name, short, long)
printOptions(out, command)
if len(command.Example) > 0 {
fmt.Fprintf(out, "# EXAMPLE\n")
fmt.Fprintf(out, "```\n%s\n```\n", command.Example)
}
if len(command.Commands()) > 0 || len(parent) > 0 {
fmt.Fprintf(out, "# SEE ALSO\n")
if len(parent) > 0 {