-
Notifications
You must be signed in to change notification settings - Fork 319
/
docgen.go
67 lines (53 loc) · 1.63 KB
/
docgen.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"log"
"path/filepath"
"strings"
"github.com/spf13/cobra"
"github.com/iotexproject/iotex-core/ioctl/cmd"
"github.com/iotexproject/iotex-core/ioctl/doc"
)
var ioctlPath string
func main() {
toolName := "ioctl"
corePath, err := filepath.Abs(".")
if err != nil {
log.Fatal(err)
}
ioctlPath = filepath.Join(corePath, "tools", toolName)
preString := `# ioctl
ioctl is a command-line interface for interacting with IoTeX blockchains.
# Build
` + "`./buildcli.sh`\n" + `
If you want to build ioctl on Windows, you need to install mingw. Package manager [Chocolatey](https://chocolatey.org/) provides an easy way to intall latest mingw.
` + "`C:\\Windows\\system32> choco install mingw`\n" + `
After this command, target bin files will be placed in ./release/ folder, upload them to
specific release so install-cli.sh can download them.
# Install
## Install released build
curl --silent https://raw.githubusercontent.com/iotexproject/iotex-core/master/install-cli.sh | sh
## Install latest build
curl https://raw.githubusercontent.com/iotexproject/iotex-core/master/install-cli.sh | sh -s "unstable"
`
rootCmd := cmd.NewIoctl()
linkHandler := func(c *cobra.Command, s string) string {
if c == rootCmd {
return "readme/" + s
}
if strings.Contains(s, "ioctl.md") {
return "../README.md"
}
return s
}
filePrepender := func(s string) string {
if strings.Contains(s, "README.md") {
return preString
}
return ""
}
path := filepath.Join(ioctlPath, "readme")
err = doc.GenMarkdownTreeCustom(rootCmd, path, toolName, ioctlPath, filePrepender, linkHandler)
if err != nil {
log.Fatal(err)
}
}