From f8b8914b8b079339fc9e3a44392817d889bc9a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erdal=20TA=C5=9EKESEN?= Date: Sun, 3 Jul 2022 17:45:45 +0300 Subject: [PATCH] Fix markdownlint errors at 'doc' Fixed rules: * MD010 - Hard tabs * MD040 - Fenced code blocks should have a language specified * MD041 - First line in a file should be a top-level heading see: https://github.com/DavidAnson/markdownlint#rules--aliases --- doc/md_docs.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/doc/md_docs.go b/doc/md_docs.go index 19d7e931..9296de17 100644 --- a/doc/md_docs.go +++ b/doc/md_docs.go @@ -30,7 +30,7 @@ func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) error { flags := cmd.NonInheritedFlags() flags.SetOutput(buf) if flags.HasAvailableFlags() { - buf.WriteString("### Options\n\n```\n") + buf.WriteString("## Options\n\n```sh\n") flags.PrintDefaults() buf.WriteString("```\n\n") } @@ -38,7 +38,7 @@ func printOptions(buf *bytes.Buffer, cmd *cobra.Command, name string) error { parentFlags := cmd.InheritedFlags() parentFlags.SetOutput(buf) if parentFlags.HasAvailableFlags() { - buf.WriteString("### Options inherited from parent commands\n\n```\n") + buf.WriteString("### Options inherited from parent commands\n\n```sh\n") parentFlags.PrintDefaults() buf.WriteString("```\n\n") } @@ -58,33 +58,33 @@ func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) buf := new(bytes.Buffer) name := cmd.CommandPath() - buf.WriteString("## " + name + "\n\n") + buf.WriteString("# " + name + "\n\n") buf.WriteString(cmd.Short + "\n\n") if len(cmd.Long) > 0 { - buf.WriteString("### Synopsis\n\n") + buf.WriteString("## Synopsis\n\n") buf.WriteString(cmd.Long + "\n\n") } if cmd.Runnable() { - buf.WriteString(fmt.Sprintf("```\n%s\n```\n\n", cmd.UseLine())) + buf.WriteString(fmt.Sprintf("```sh\n%s\n```\n\n", cmd.UseLine())) } if len(cmd.Example) > 0 { - buf.WriteString("### Examples\n\n") - buf.WriteString(fmt.Sprintf("```\n%s\n```\n\n", cmd.Example)) + buf.WriteString("## Examples\n\n") + buf.WriteString(fmt.Sprintf("```sh\n%s\n```\n\n", cmd.Example)) } if err := printOptions(buf, cmd, name); err != nil { return err } if hasSeeAlso(cmd) { - buf.WriteString("### SEE ALSO\n\n") + buf.WriteString("## SEE ALSO\n\n") if cmd.HasParent() { parent := cmd.Parent() pname := parent.CommandPath() link := pname + ".md" link = strings.ReplaceAll(link, " ", "_") - buf.WriteString(fmt.Sprintf("* [%s](%s)\t - %s\n", pname, linkHandler(link), parent.Short)) + buf.WriteString(fmt.Sprintf("* [%s](%s) - %s\n", pname, linkHandler(link), parent.Short)) cmd.VisitParents(func(c *cobra.Command) { if c.DisableAutoGenTag { cmd.DisableAutoGenTag = c.DisableAutoGenTag @@ -102,9 +102,8 @@ func GenMarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) cname := name + " " + child.Name() link := cname + ".md" link = strings.ReplaceAll(link, " ", "_") - buf.WriteString(fmt.Sprintf("* [%s](%s)\t - %s\n", cname, linkHandler(link), child.Short)) + buf.WriteString(fmt.Sprintf("* [%s](%s) - %s\n", cname, linkHandler(link), child.Short)) } - buf.WriteString("\n") } if !cmd.DisableAutoGenTag { buf.WriteString("###### Auto generated by spf13/cobra on " + time.Now().Format("2-Jan-2006") + "\n")