Changeset View
Changeset View
Standalone View
Standalone View
doc/rpc/generate.go
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | func main() { | ||||
g := Group{ | g := Group{ | ||||
Name: lastGroupName, | Name: lastGroupName, | ||||
Commands: commands, | Commands: commands, | ||||
Index: len(groups), | Index: len(groups), | ||||
} | } | ||||
groups = append(groups, g) | groups = append(groups, g) | ||||
tmpl := template.Must(template.ParseFiles(path.Join(srcdir, "doc", "rpc", "command-template.html"))) | tmpl := template.Must(template.ParseFiles(path.Join(srcdir, "doc", "rpc", "command-template.md"))) | ||||
for _, group := range groups { | for _, group := range groups { | ||||
groupname := group.Name | groupname := group.Name | ||||
rpcdocdir := path.Join("doc", "rpc", "en") | rpcdocdir := path.Join("doc", "rpc", "en") | ||||
dirname := path.Join(rpcdocdir, version, "rpc", groupname) | dirname := path.Join(rpcdocdir, version, "rpc", groupname) | ||||
err := os.MkdirAll(dirname, 0777) | err := os.MkdirAll(dirname, 0777) | ||||
if err != nil { | if err != nil { | ||||
log.Fatalf("Cannot make directory %s: %s", dirname, err.Error()) | log.Fatalf("Cannot make directory %s: %s", dirname, err.Error()) | ||||
} | } | ||||
for _, command := range group.Commands { | for _, command := range group.Commands { | ||||
name := command.Name | name := command.Name | ||||
address := fmt.Sprintf("%s/%s.html", dirname, name) | address := fmt.Sprintf("%s/%s.md", dirname, name) | ||||
permalink := fmt.Sprintf("en/doc/%s/rpc/%s/%s/", version, groupname, name) | permalink := fmt.Sprintf("en/doc/%s/rpc/%s/%s/", version, groupname, name) | ||||
err = tmpl.Execute(open(address), CommandData{ | err = tmpl.Execute(open(address), CommandData{ | ||||
Version: version, | Version: version, | ||||
Name: name, | Name: name, | ||||
Description: command.Description, | Description: command.Description, | ||||
Group: groupname, | Group: groupname, | ||||
Permalink: permalink, | Permalink: permalink, | ||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
log.Fatalf("Cannot make command file %s: %s", name, err.Error()) | log.Fatalf("Cannot make command file %s: %s", name, err.Error()) | ||||
} | } | ||||
} | } | ||||
address := path.Join(rpcdocdir, version, "rpc", "index.html") | address := path.Join(rpcdocdir, version, "rpc", "index.md") | ||||
permalink := fmt.Sprintf("en/doc/%s/rpc/", version) | permalink := fmt.Sprintf("en/doc/%s/rpc/", version) | ||||
err = tmpl.Execute(open(address), CommandData{ | err = tmpl.Execute(open(address), CommandData{ | ||||
Version: version, | Version: version, | ||||
Name: "rpcindex", | Name: "rpcindex", | ||||
Description: "", | Description: "", | ||||
Group: "index", | Group: "index", | ||||
Permalink: permalink, | Permalink: permalink, | ||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
log.Fatalf("Cannot make index file: %s", err.Error()) | log.Fatalf("Cannot make index file: %s", err.Error()) | ||||
} | } | ||||
address = path.Join(rpcdocdir, version, "index.html") | address = path.Join(rpcdocdir, version, "index.md") | ||||
permalink = fmt.Sprintf("en/doc/%s/", version) | permalink = fmt.Sprintf("en/doc/%s/", version) | ||||
err = tmpl.Execute(open(address), CommandData{ | err = tmpl.Execute(open(address), CommandData{ | ||||
Version: version, | Version: version, | ||||
Name: "index", | Name: "index", | ||||
Description: "", | Description: "", | ||||
Group: "index", | Group: "index", | ||||
Permalink: permalink, | Permalink: permalink, | ||||
}) | }) | ||||
Show All 29 Lines |