From 01ec49c79ef5b879eb73ba429a98cc104d2dd22f Mon Sep 17 00:00:00 2001 From: Zoran Regvart Date: Wed, 24 Aug 2022 17:24:02 +0100 Subject: [PATCH] fix: correct command path in see_also for YAML doc 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 https://github.com/spf13/cobra/pull/1771 --- doc/yaml_docs.go | 2 +- doc/yaml_docs_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/yaml_docs.go b/doc/yaml_docs.go index 4502536..73abc6e 100644 --- a/doc/yaml_docs.go +++ b/doc/yaml_docs.go @@ -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 } diff --git a/doc/yaml_docs_test.go b/doc/yaml_docs_test.go index b14eefe..41d2a19 100644 --- a/doc/yaml_docs_test.go +++ b/doc/yaml_docs_test.go @@ -2,6 +2,7 @@ package doc_test import ( "bytes" + "fmt" "io/ioutil" "os" "path/filepath" @@ -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) {