Remove old code
This commit is contained in:
98
class.go
98
class.go
@@ -266,104 +266,6 @@ func getConstructor(dataContainer *goquery.Selection) (Constructor, error) {
|
|||||||
return resConstructor, nil
|
return resConstructor, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement parsing comments for return values
|
|
||||||
// Something like "---returns (something) -> comment"
|
|
||||||
// Where "-> comment" is only shown if there's a comment
|
|
||||||
// And "---returns" only if there's a return type
|
|
||||||
// This is NOT a luals annotation because we can not use annotations on @overload
|
|
||||||
// But just a regular plain Lua comment
|
|
||||||
// TODO: Implement parsing comments for classes and constructors
|
|
||||||
func getConstructors(doc *goquery.Document) ([]Constructor, error) {
|
|
||||||
res := []Constructor{}
|
|
||||||
|
|
||||||
codeblocks := doc.Find("div.floatright > div.codecontainer")
|
|
||||||
if codeblocks.Length() == 0 {
|
|
||||||
return res, fmt.Errorf("no codeblocks found")
|
|
||||||
}
|
|
||||||
|
|
||||||
// The first code block should be the constructor
|
|
||||||
// So far I have not found any classes with overloaded constructors...
|
|
||||||
// So I can not handle that case yet
|
|
||||||
constructorBlock := codeblocks.Eq(0)
|
|
||||||
constructor := constructorBlock.Find("div.function")
|
|
||||||
paramTypes := constructor.Find("span.type")
|
|
||||||
paramNames := constructor.Find("span.parameter")
|
|
||||||
|
|
||||||
resConstructor := Constructor{}
|
|
||||||
paramTypes.Each(func(i int, s *goquery.Selection) {
|
|
||||||
pname := strings.TrimSpace(paramNames.Eq(i).Text())
|
|
||||||
ptype := strings.TrimSpace(paramTypes.Eq(i).Text())
|
|
||||||
ptype = MapType(ptype)
|
|
||||||
|
|
||||||
resConstructor.Params = append(resConstructor.Params, Param{
|
|
||||||
Name: pname,
|
|
||||||
Type: ptype,
|
|
||||||
Comment: "",
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
constructorDetails := constructorBlock.Children().Eq(1)
|
|
||||||
constructorParameterDetails := constructorDetails.Find("span.parameter")
|
|
||||||
constructorParameterDetails.Each(func(i int, s *goquery.Selection) {
|
|
||||||
param := strings.TrimSpace(s.Text())
|
|
||||||
parameterParent := s.Parent()
|
|
||||||
parameterDescription := parameterParent.Text()
|
|
||||||
parameterDescription = strings.ReplaceAll(parameterDescription, fmt.Sprintf("\n%s\n", param), "")
|
|
||||||
parameterDescription = strings.TrimSpace(parameterDescription)
|
|
||||||
resConstructor.Params[i].Comment = parameterDescription
|
|
||||||
})
|
|
||||||
|
|
||||||
constructorBlock.Find("div:not(.function):not(.indented) > p:not(:has(*))").Each(func(i int, s *goquery.Selection) {
|
|
||||||
resConstructor.Comment += strings.TrimSpace(s.Text()) + "\n"
|
|
||||||
resConstructor.Comment = strings.TrimSpace(resConstructor.Comment)
|
|
||||||
})
|
|
||||||
|
|
||||||
return append(res, resConstructor), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getFields(doc *goquery.Document) ([]Field, error) {
|
|
||||||
res := []Field{}
|
|
||||||
properties := doc.Find("div.floatright > div.codecontainer#Properties")
|
|
||||||
properties.ChildrenFiltered("div").Each(func(i int, s *goquery.Selection) {
|
|
||||||
property := Field{}
|
|
||||||
property.Name = strings.TrimSpace(s.Find("span.property").Text())
|
|
||||||
property.Type = strings.TrimSpace(s.Find("span.type").Text())
|
|
||||||
property.Type = MapType(property.Type)
|
|
||||||
comment := s.Find("td[align='right']").Text()
|
|
||||||
if comment != "" {
|
|
||||||
property.Comment = strings.TrimSpace(comment)
|
|
||||||
}
|
|
||||||
res = append(res, property)
|
|
||||||
})
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Implement parsing return value types and comments
|
|
||||||
func getMethods(doc *goquery.Document) ([]Method, error) {
|
|
||||||
res := []Method{}
|
|
||||||
|
|
||||||
codeblocks := doc.Find("div.floatright > div.codecontainer")
|
|
||||||
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 = append(res, method)
|
|
||||||
})
|
|
||||||
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func CleanUp(s string) string {
|
func CleanUp(s string) string {
|
||||||
s = strings.TrimSpace(s)
|
s = strings.TrimSpace(s)
|
||||||
s = strings.ReplaceAll(s, "\t", " ")
|
s = strings.ReplaceAll(s, "\t", " ")
|
||||||
|
|||||||
Reference in New Issue
Block a user