aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/spf13/cobra/doc/md_docs.md
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-02-05 22:03:19 +0100
committerMichael Muré <batolettre@gmail.com>2020-02-05 22:33:03 +0100
commit1d4bb7ceb0cef79d68df0bacc913b01e40e6ddd6 (patch)
treee088b0fa43058afde1db71541d8fcb4b94905d6e /vendor/github.com/spf13/cobra/doc/md_docs.md
parentf093be96e98284580d61664adecd0a2ff8b354e4 (diff)
downloadgit-bug-1d4bb7ceb0cef79d68df0bacc913b01e40e6ddd6.tar.gz
migrate to go modules
Diffstat (limited to 'vendor/github.com/spf13/cobra/doc/md_docs.md')
-rw-r--r--vendor/github.com/spf13/cobra/doc/md_docs.md115
1 files changed, 0 insertions, 115 deletions
diff --git a/vendor/github.com/spf13/cobra/doc/md_docs.md b/vendor/github.com/spf13/cobra/doc/md_docs.md
deleted file mode 100644
index 56ce9fe8..00000000
--- a/vendor/github.com/spf13/cobra/doc/md_docs.md
+++ /dev/null
@@ -1,115 +0,0 @@
-# Generating Markdown Docs For Your Own cobra.Command
-
-Generating man pages from a cobra command is incredibly easy. An example is as follows:
-
-```go
-package main
-
-import (
- "log"
-
- "github.com/spf13/cobra"
- "github.com/spf13/cobra/doc"
-)
-
-func main() {
- cmd := &cobra.Command{
- Use: "test",
- Short: "my test program",
- }
- err := doc.GenMarkdownTree(cmd, "/tmp")
- if err != nil {
- log.Fatal(err)
- }
-}
-```
-
-That will get you a Markdown document `/tmp/test.md`
-
-## Generate markdown docs for the entire command tree
-
-This program can actually generate docs for the kubectl command in the kubernetes project
-
-```go
-package main
-
-import (
- "log"
- "io/ioutil"
- "os"
-
- "k8s.io/kubernetes/pkg/kubectl/cmd"
- cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
-
- "github.com/spf13/cobra/doc"
-)
-
-func main() {
- kubectl := cmd.NewKubectlCommand(cmdutil.NewFactory(nil), os.Stdin, ioutil.Discard, ioutil.Discard)
- err := doc.GenMarkdownTree(kubectl, "./")
- if err != nil {
- log.Fatal(err)
- }
-}
-```
-
-This will generate a whole series of files, one for each command in the tree, in the directory specified (in this case "./")
-
-## Generate markdown docs for a single command
-
-You may wish to have more control over the output, or only generate for a single command, instead of the entire command tree. If this is the case you may prefer to `GenMarkdown` instead of `GenMarkdownTree`
-
-```go
- out := new(bytes.Buffer)
- err := doc.GenMarkdown(cmd, out)
- if err != nil {
- log.Fatal(err)
- }
-```
-
-This will write the markdown doc for ONLY "cmd" into the out, buffer.
-
-## Customize the output
-
-Both `GenMarkdown` and `GenMarkdownTree` have alternate versions with callbacks to get some control of the output:
-
-```go
-func GenMarkdownTreeCustom(cmd *Command, dir string, filePrepender, linkHandler func(string) string) error {
- //...
-}
-```
-
-```go
-func GenMarkdownCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string) string) error {
- //...
-}
-```
-
-The `filePrepender` will prepend the return value given the full filepath to the rendered Markdown file. A common use case is to add front matter to use the generated documentation with [Hugo](http://gohugo.io/):
-
-```go
-const fmTemplate = `---
-date: %s
-title: "%s"
-slug: %s
-url: %s
----
-`
-
-filePrepender := func(filename string) string {
- now := time.Now().Format(time.RFC3339)
- name := filepath.Base(filename)
- base := strings.TrimSuffix(name, path.Ext(name))
- url := "/commands/" + strings.ToLower(base) + "/"
- return fmt.Sprintf(fmTemplate, now, strings.Replace(base, "_", " ", -1), base, url)
-}
-```
-
-The `linkHandler` can be used to customize the rendered internal links to the commands, given a filename:
-
-```go
-linkHandler := func(name string) string {
- base := strings.TrimSuffix(name, path.Ext(name))
- return "/commands/" + strings.ToLower(base) + "/"
-}
-```