diff --git a/class.go b/class.go index 346fecb..70be45a 100644 --- a/class.go +++ b/class.go @@ -161,6 +161,13 @@ func ParseClass(file string) (*Class, error) { } res.Fields = append(res.Fields, field) }) + } else { + method, err := parseMethod(s) + if err != nil { + Error.Printf("Error parsing method: %v", err) + return + } + res.Methods = append(res.Methods, method) } }) @@ -311,6 +318,58 @@ func parseField(s *goquery.Selection) (Field, error) { }) res.Comment = strings.ReplaceAll(res.Comment, "\n--", ". ") + return res, nil +} + +func parseMethod(s *goquery.Selection) (Method, error) { + res := Method{} + + id, ok := s.Attr("id") + if !ok { + return res, fmt.Errorf("no id found") + } + res.Name = id + + returns := s.Find("span.keyword") + if returns.Length() != 0 { + returnsText := CleanUp(returns.Text()) + returnsText = strings.ReplaceAll(returnsText, "function", "") + returnsText = CleanUp(returnsText) + + res.Returns = append(res.Returns, Return{ + Type: MapType(returnsText), + Comment: "", + }) + } + + types := s.Find("span.type") + parameters := s.Find("span.parameter") + types.Each(func(i int, s *goquery.Selection) { + res.Params = append(res.Params, Param{ + Name: CleanUp(parameters.Eq(i).Text()), + Type: MapType(CleanUp(types.Eq(i).Text())), + Comment: "", + }) + }) + + //
+ // function var add(CargoBay other)
+ //
Returns
+ //+ // nothing + //
+ //