Implement parsing methods
This commit is contained in:
20
main.go
20
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":
|
||||
|
Reference in New Issue
Block a user