Skip to content

Commit

Permalink
added linkHandler to all commands
Browse files Browse the repository at this point in the history
  • Loading branch information
hassansin committed May 24, 2017
1 parent 70a3fb8 commit 8a008f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ amqptools consume [flags]
```

### SEE ALSO
* [amqptools](amqptools.md) - A brief description of your application
* [amqptools](#amqptools) - A brief description of your application

## amqptools publish

Expand Down Expand Up @@ -110,5 +110,5 @@ amqptools publish [flags] [message]
```

### SEE ALSO
* [amqptools](amqptools.md) - A brief description of your application
* [amqptools](#amqptools) - A brief description of your application

14 changes: 8 additions & 6 deletions cmd/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import (
"github.com/spf13/cobra/doc"
)

func linkHandler(name string) string {
base := strings.TrimSuffix(name, path.Ext(name))
return "#" + strings.Replace(base, "_", "-", 5)
}

// consumeCmd represents the consume command
var docCmd = &cobra.Command{
Use: "doc",
Expand All @@ -20,20 +25,17 @@ var docCmd = &cobra.Command{
cmd.SilenceErrors = true

rootDoc := new(bytes.Buffer)
if err := doc.GenMarkdownCustom(RootCmd, rootDoc, func(name string) string {
base := strings.TrimSuffix(name, path.Ext(name))
return "#" + strings.Replace(base, "_", "-", 5)
}); err != nil {
if err := doc.GenMarkdownCustom(RootCmd, rootDoc, linkHandler); err != nil {
return err
}

consumeDoc := new(bytes.Buffer)
if err := doc.GenMarkdown(consumeCmd, consumeDoc); err != nil {
if err := doc.GenMarkdownCustom(consumeCmd, consumeDoc, linkHandler); err != nil {
return err
}

produceDoc := new(bytes.Buffer)
if err := doc.GenMarkdown(produceCmd, produceDoc); err != nil {
if err := doc.GenMarkdownCustom(produceCmd, produceDoc, linkHandler); err != nil {
return err
}

Expand Down

0 comments on commit 8a008f6

Please sign in to comment.