Skip to content

Commit

Permalink
fix: correct command path in see_also for YAML doc (#1771)
Browse files Browse the repository at this point in the history
The `see_also` section for child commands would include only the name of
the commands. This adds the whole path, similar to how it's done for the
other documentation formats.
  • Loading branch information
zregvart authored Aug 13, 2022
1 parent 6bf8cd8 commit 7790bf9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/yaml_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func GenYamlCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) str
if !child.IsAvailableCommand() || child.IsAdditionalHelpTopicCommand() {
continue
}
result = append(result, child.Name()+" - "+child.Short)
result = append(result, child.CommandPath()+" - "+child.Short)
}
yamlDoc.SeeAlso = result
}
Expand Down
2 changes: 2 additions & 0 deletions doc/yaml_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package doc

import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
Expand All @@ -24,6 +25,7 @@ func TestGenYamlDoc(t *testing.T) {
checkStringContains(t, output, "rootflag")
checkStringContains(t, output, rootCmd.Short)
checkStringContains(t, output, echoSubCmd.Short)
checkStringContains(t, output, fmt.Sprintf("- %s - %s", echoSubCmd.CommandPath(), echoSubCmd.Short))
}

func TestGenYamlNoTag(t *testing.T) {
Expand Down

0 comments on commit 7790bf9

Please sign in to comment.