From 901232d293ff6311f6e2869e59c91f5fd0a04709 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Thu, 12 Sep 2024 09:00:27 +0200 Subject: [PATCH] Implement parsing methods --- main.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/main.go b/main.go index b902db2..8e6a46f 100644 --- a/main.go +++ b/main.go @@ -138,6 +138,24 @@ func ParseFile(filename string) (*Class, error) { res.Fields = append(res.Fields, property) }) + codeblocks.ChildrenFiltered("div.function").Each(func(i int, s *goquery.Selection) { + method := Method{} + method.Name = strings.TrimSpace(s.AttrOr("id", "")) + method.Comment = strings.TrimSpace(s.Find("span.comment").Text()) + + types := s.Find("span.type") + parameters := s.Find("span.parameter") + types.Each(func(i int, s *goquery.Selection) { + param := Param{} + param.Name = strings.TrimSpace(parameters.Eq(i).Text()) + param.Type = strings.TrimSpace(types.Eq(i).Text()) + param.Type = MapType(param.Type) + method.Params = append(method.Params, param) + }) + + res.Methods = append(res.Methods, method) + }) + spew.Dump(res) return &res, nil @@ -151,6 +169,8 @@ func MapType(t string) string { return "number" case "float": return "number" + case "double": + return "number" case "bool": return "boolean" case "table_t":