Skip to content

Commit 5040723

Browse files
jon4hzmuesli
authored andcommitted
feat: add support for examples
1 parent b18accb commit 5040723

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

mango.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type Command struct {
2222
Name string
2323
Short string
2424
Usage string
25+
Example string
2526
Flags map[string]Flag
2627
Commands map[string]*Command
2728
}
@@ -176,6 +177,24 @@ func (m ManPage) buildCommand(w Builder, c Command) {
176177
w.IndentEnd()
177178
}
178179
}
180+
181+
if c.Example != "" {
182+
if c.Name == m.Root.Name {
183+
w.Section("Examples")
184+
w.TaggedParagraph(-1)
185+
} else {
186+
w.TaggedParagraph(-1)
187+
w.TextBold("EXAMPLES")
188+
w.Indent(4)
189+
}
190+
w.Text(c.Example)
191+
192+
if c.Name == m.Root.Name {
193+
w.EndSection()
194+
} else {
195+
w.IndentEnd()
196+
}
197+
}
179198
}
180199

181200
// Build generates the man page.

0 commit comments

Comments
 (0)