Add support for constructor comments (and refactor the template a little)

This commit is contained in:
2024-09-12 20:32:05 +02:00
parent a9b0ccb3ee
commit e85dca2416
2 changed files with 34 additions and 24 deletions

View File

@@ -144,6 +144,7 @@ func ParseClass(file string) (*Class, error) {
// 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{}
@@ -184,6 +185,12 @@ func getConstructors(doc *goquery.Document) ([]Constructor, error) {
resConstructor.Params[i].Comment = parameterDescription
})
constructorBlock.Find(":not(function)").Children().Each(func(i int, s *goquery.Selection) {
if s.Is("p") {
resConstructor.Comment = strings.TrimSpace(s.Text())
}
})
spew.Dump(resConstructor)
return append(res, resConstructor), nil
}