MCPcopy Index your code
hub / github.com/rilldata/rill / genMarkdownCustom

Function genMarkdownCustom

cli/cmd/docs/generate_cli.go:91–178  ·  view source on GitHub ↗
(cmd *cobra.Command, w io.Writer)

Source from the content-addressed store, hash-verified

89}
90
91func genMarkdownCustom(cmd *cobra.Command, w io.Writer) error {
92 cmd.InitDefaultHelpCmd()
93 cmd.InitDefaultHelpFlag()
94
95 buf := new(bytes.Buffer)
96 name := cmd.CommandPath()
97
98 /*
99 ---
100 title: CLI cheat sheet
101 sidebar_position: 40
102 ---
103 */
104 buf.WriteString("---\n")
105 buf.WriteString("note: GENERATED. DO NOT EDIT.\n")
106 if cmd.Parent() == nil {
107 buf.WriteString("title: CLI usage\n")
108 buf.WriteString("sidebar_position: 15\n")
109 } else {
110 buf.WriteString("title: " + name + "\n")
111 }
112 buf.WriteString("---\n")
113
114 buf.WriteString("## " + name + "\n\n")
115 buf.WriteString(cmd.Short + "\n\n")
116 if cmd.Long != "" {
117 buf.WriteString("### Synopsis\n\n")
118 buf.WriteString(cmd.Long + "\n\n")
119 }
120
121 if cmd.Runnable() {
122 fmt.Fprintf(buf, "```\n%s\n```\n\n", cmd.UseLine())
123 }
124
125 if cmd.Example != "" {
126 buf.WriteString("### Examples\n\n")
127 fmt.Fprintf(buf, "```\n%s\n```\n\n", cmd.Example)
128 }
129
130 if err := printOptions(buf, cmd); err != nil {
131 return err
132 }
133 if hasSeeAlso(cmd) {
134 buf.WriteString("### SEE ALSO\n\n")
135 if cmd.HasParent() {
136 parent := cmd.Parent()
137 pname := parent.CommandPath()
138 var link string
139 if parent.Parent() == nil {
140 link = "cli.md"
141 } else {
142 link = parent.Name() + ".md"
143 }
144
145 if len(cmd.Commands()) > 0 {
146 link = filepath.Join("..", link)
147 }
148

Callers 1

genMarkdownTreeCustomFunction · 0.85

Calls 4

printOptionsFunction · 0.85
hasSeeAlsoFunction · 0.85
byNameTypeAlias · 0.85
NameMethod · 0.65

Tested by

no test coverage detected