From f8ce68f062a42ed5b2c8b2bdf2d63193b116b3ab Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 22 Oct 2020 09:57:36 +0000 Subject: [PATCH] Remove SEE ALSO from markdown docs generation --- Makefile | 1 - internal/docs/markdown.go | 25 ------------------------- internal/docs/markdown_test.go | 4 ---- 3 files changed, 30 deletions(-) diff --git a/Makefile b/Makefile index ad16069ee..859461984 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,6 @@ site-docs: site git -C site pull git -C site rm 'manual/gh*.md' 2>/dev/null || true go run ./cmd/gen-docs --website --doc-path site/manual - for f in site/manual/gh*.md; do sed -i.bak -e '/^### SEE ALSO/,$$d' "$$f"; done rm -f site/manual/*.bak git -C site add 'manual/gh*.md' git -C site commit -m 'update help docs' || true diff --git a/internal/docs/markdown.go b/internal/docs/markdown.go index 4f57a07cf..983a7cd7b 100644 --- a/internal/docs/markdown.go +++ b/internal/docs/markdown.go @@ -6,7 +6,6 @@ import ( "io" "os" "path/filepath" - "sort" "strings" "github.com/spf13/cobra" @@ -63,30 +62,6 @@ func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) if err := printOptions(buf, cmd, name); err != nil { return err } - if hasSeeAlso(cmd) { - buf.WriteString("### SEE ALSO\n\n") - if cmd.HasParent() { - parent := cmd.Parent() - pname := parent.CommandPath() - link := pname + ".md" - link = strings.Replace(link, " ", "_", -1) - buf.WriteString(fmt.Sprintf("* [%s](%s)\t - %s\n", pname, linkHandler(link), parent.Short)) - } - - children := cmd.Commands() - sort.Sort(byName(children)) - - for _, child := range children { - if !child.IsAvailableCommand() || child.IsAdditionalHelpTopicCommand() { - continue - } - cname := name + " " + child.Name() - link := cname + ".md" - link = strings.Replace(link, " ", "_", -1) - buf.WriteString(fmt.Sprintf("* [%s](%s)\t - %s\n", cname, linkHandler(link), child.Short)) - } - buf.WriteString("\n") - } _, err := buf.WriteTo(w) return err } diff --git a/internal/docs/markdown_test.go b/internal/docs/markdown_test.go index f5813f7db..bfb63bf19 100644 --- a/internal/docs/markdown_test.go +++ b/internal/docs/markdown_test.go @@ -22,8 +22,6 @@ func TestGenMdDoc(t *testing.T) { checkStringContains(t, output, echoCmd.Example) checkStringContains(t, output, "boolone") checkStringContains(t, output, "rootflag") - checkStringContains(t, output, rootCmd.Short) - checkStringContains(t, output, echoSubCmd.Short) checkStringOmits(t, output, deprecatedCmd.Short) checkStringContains(t, output, "Options inherited from parent commands") } @@ -59,8 +57,6 @@ func TestGenMdNoHiddenParents(t *testing.T) { checkStringContains(t, output, echoCmd.Example) checkStringContains(t, output, "boolone") checkStringOmits(t, output, "rootflag") - checkStringContains(t, output, rootCmd.Short) - checkStringContains(t, output, echoSubCmd.Short) checkStringOmits(t, output, deprecatedCmd.Short) checkStringOmits(t, output, "Options inherited from parent commands") }