mirror of https://github.com/Hilbis/Hilbish
feat: use goroutines for doc gen loop
parent
079bedc6dc
commit
4f959c326a
|
@ -9,6 +9,7 @@ import (
|
||||||
"go/token"
|
"go/token"
|
||||||
"strings"
|
"strings"
|
||||||
"os"
|
"os"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
var header = `---
|
var header = `---
|
||||||
|
@ -146,11 +147,18 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
wg.Add(len(docs) * 2)
|
||||||
|
|
||||||
for mod, v := range docs {
|
for mod, v := range docs {
|
||||||
modN := mod
|
modN := mod
|
||||||
if mod == "main" {
|
if mod == "main" {
|
||||||
modN = "hilbish"
|
modN = "hilbish"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
go func(modName string) {
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
f, _ := os.Create("docs/api/" + modN + ".md")
|
f, _ := os.Create("docs/api/" + modN + ".md")
|
||||||
f.WriteString(fmt.Sprintf(header, modN, v.ShortDescription))
|
f.WriteString(fmt.Sprintf(header, modN, v.ShortDescription))
|
||||||
f.WriteString(fmt.Sprintf("## Introduction\n%s\n\n## Functions\n", v.Description))
|
f.WriteString(fmt.Sprintf("## Introduction\n%s\n\n## Functions\n", v.Description))
|
||||||
|
@ -163,12 +171,16 @@ func main() {
|
||||||
}
|
}
|
||||||
f.WriteString("\n")
|
f.WriteString("\n")
|
||||||
}
|
}
|
||||||
|
}(modN)
|
||||||
|
|
||||||
|
go func(md, modName string) {
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
ff, _ := os.Create("emmyLuaDocs/" + modN + ".lua")
|
ff, _ := os.Create("emmyLuaDocs/" + modN + ".lua")
|
||||||
ff.WriteString("--- @meta\n\nlocal " + modN + " = {}\n\n")
|
ff.WriteString("--- @meta\n\nlocal " + modN + " = {}\n\n")
|
||||||
for _, em := range emmyDocs[mod] {
|
for _, em := range emmyDocs[md] {
|
||||||
funcdocs := []string{}
|
funcdocs := []string{}
|
||||||
for _, dps := range docs[mod].Docs{
|
for _, dps := range docs[md].Docs{
|
||||||
if dps.FuncName == em.FuncName {
|
if dps.FuncName == em.FuncName {
|
||||||
funcdocs = dps.Doc
|
funcdocs = dps.Doc
|
||||||
}
|
}
|
||||||
|
@ -180,5 +192,7 @@ func main() {
|
||||||
ff.WriteString("function " + modN + "." + em.FuncName + "(" + strings.Join(em.Params, ", ") + ") end\n\n")
|
ff.WriteString("function " + modN + "." + em.FuncName + "(" + strings.Join(em.Params, ", ") + ") end\n\n")
|
||||||
}
|
}
|
||||||
ff.WriteString("return " + modN + "\n")
|
ff.WriteString("return " + modN + "\n")
|
||||||
|
}(mod, modN)
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue