Skip to content

Commit

Permalink
fix: correct command path in see_also for YAML doc
Browse files Browse the repository at this point in the history
The `see_also` section for child commands would include only the name of
command. This adds the whole path, similar to how it's done for the
other documentation formats.

Merge spf13/cobra#1771
  • Loading branch information
zregvart authored and hoshsadiq committed Aug 24, 2022
1 parent a4ce13a commit 01ec49c
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
Expand Up @@ -129,7 +129,7 @@ func GenYamlCustom(cmd *zulu.Command, w io.Writer, linkHandler func(string) stri
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
Expand Up @@ -2,6 +2,7 @@ package doc_test

import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
Expand All @@ -25,6 +26,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 01ec49c

Please sign in to comment.