MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / GenManPages

Function GenManPages

cmd/internal/commands/doc.go:37–60  ·  view source on GitHub ↗

GenManPages generates man pages for the given root command.

(root *cobra.Command)

Source from the content-addressed store, hash-verified

35
36// GenManPages generates man pages for the given root command.
37func GenManPages(root *cobra.Command) *cobra.Command {
38 cmd := &cobra.Command{
39 Use: "gen-man-pages",
40 Hidden: true,
41 Short: fmt.Sprintf("Generate man pages for %s", root.Name()),
42 RunE: func(cmd *cobra.Command, args []string) error {
43 dir, _ := cmd.Flags().GetString("out")
44 if _, err := os.Stat(dir); os.IsNotExist(err) {
45 if err := os.MkdirAll(dir, 0o755); err != nil {
46 return err
47 }
48 }
49 disableAutoGenTag(root)
50 return doc.GenManTree(root, &doc.GenManHeader{
51 Title: strings.ToUpper(root.Name()),
52 Section: "1",
53 Manual: root.Root().Short,
54 Source: "TTN",
55 }, dir)
56 },
57 }
58 cmd.Flags().StringP("out", "o", "doc", "output directory")
59 return cmd
60}
61
62const MDDocFrontmatterTemplate = `---
63title: "%s"

Callers 2

root.goFile · 0.92
root.goFile · 0.92

Calls 3

disableAutoGenTagFunction · 0.85
FlagsMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected