mirror of https://github.com/Hilbis/Hilbish
feat: output docs to a docs folder, allow multiline docs
parent
71b72bbdd4
commit
a2f54b627b
|
@ -11,6 +11,8 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
// feel free to clean this up
|
||||
// it works, dont really care about the code
|
||||
func main() {
|
||||
fset := token.NewFileSet()
|
||||
|
||||
|
@ -37,31 +39,41 @@ func main() {
|
|||
|
||||
prefix := map[string]string{
|
||||
"main": "hsh",
|
||||
"hilbish": "hl",
|
||||
"fs": "f",
|
||||
"commander": "c",
|
||||
"bait": "b",
|
||||
}
|
||||
docs := make(map[string][]string)
|
||||
|
||||
for l, f := range pkgs {
|
||||
fmt.Println("------", l)
|
||||
p := doc.New(f, "./", doc.AllDecls)
|
||||
for _, t := range p.Funcs {
|
||||
if !strings.HasPrefix(t.Name, prefix[l]) || t.Name == "Loader" { continue }
|
||||
mod := l
|
||||
if strings.HasPrefix(t.Name, "hl") { mod = "hilbish" }
|
||||
if !strings.HasPrefix(t.Name, prefix[mod]) || t.Name == "Loader" { continue }
|
||||
parts := strings.Split(t.Doc, "\n")
|
||||
funcsig := parts[0]
|
||||
doc := parts[1]
|
||||
doc := parts[1:]
|
||||
|
||||
fmt.Println(funcsig, ">", doc)
|
||||
docs[mod] = append(docs[mod], funcsig + " > " + strings.Join(doc, "\n"))
|
||||
}
|
||||
for _, t := range p.Types {
|
||||
for _, m := range t.Methods {
|
||||
if !strings.HasPrefix(m.Name, prefix[l]) || m.Name == "Loader" { continue }
|
||||
parts := strings.Split(m.Doc, "\n")
|
||||
funcsig := parts[0]
|
||||
doc := parts[1]
|
||||
doc := parts[1:]
|
||||
|
||||
fmt.Println(funcsig, ">", doc)
|
||||
docs[l] = append(docs[l], funcsig + " > " + strings.Join(doc, "\n"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for mod, v := range docs {
|
||||
if mod == "main" { mod = "global" }
|
||||
os.Mkdir("docs", 0744)
|
||||
f, _ := os.Create("docs/" + mod + ".txt")
|
||||
f.WriteString(strings.Join(v, "\n") + "\n")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue