Home

tmpl @dc19c1b9938cc12fa1bec5fef4b1a1b30b8b2561 - refs - log -
-
https://git.jolheiser.com/tmpl.git
Template automation
tmpl / docs.go
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// +build docs

package main

import (
	"os"
	"strings"

	"go.jolheiser.com/tmpl/cmd"
)

func main() {
	app := cmd.NewApp()

	fi, err := os.Create("DOCS.md")
	if err != nil {
		panic(err)
	}
	defer fi.Close()

	md, err := app.ToMarkdown()
	if err != nil {
		panic(err)
	}

	// CLI ToMarkdown issue related to man-pages
	md = md[strings.Index(md, "#"):]

	if _, err := fi.WriteString(md); err != nil {
		panic(err)
	}
}