md_docs.md
This file
Path
md_docs.md
35 lines · 1011 bytes · Markdown
Last changed by
Merge pull request #87 from eparis/gen-md-docEric Parisbefore adoptionc0da825
History of this fileTake it
Merge pull request #87 from eparis/gen-md-docEric Parisbefore adoptionc0da825
lines 1–35why, one step back1# Generating Markdown Docs For Your Own cobra.Command23## Generate markdown docs for the entire command tree45This program can actually generate docs for the kubectl command in the kubernetes project67```go8package main910import (11 "io/ioutil"12 "os"1314 "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd"15 "github.com/spf13/cobra"16)1718func main() {19 kubectl := cmd.NewFactory(nil).NewKubectlCommand(os.Stdin, ioutil.Discard, ioutil.Discard)20 cobra.GenMarkdownTree(kubectl, "./")21}22```2324This will generate a whole series of files, one for each command in the tree, in the directory specified (in this case "./")2526## Generate markdown docs for a single command2728You 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`2930```go31 out := new(bytes.Buffer)32 cobra.GenMarkdown(cmd, out)33```3435This will write the markdown doc for ONLY "cmd" into the out, buffer.