Hallucinate fixes to return types and comments

This commit is contained in:
2025-07-20 17:07:11 +02:00
parent 49593a0861
commit 8e1561fff9
3 changed files with 224 additions and 21 deletions

View File

@@ -11,25 +11,28 @@
{{- range $param := $method.Params}}
---@param {{.Name}} {{.Type}}{{if ne .Comment ""}} {{.Comment}}{{end}}
{{- end}}
{{- range $ret := $method.Returns}}
---@return {{.Type}}{{if ne .Comment ""}} #{{.Comment}}{{end}}
{{- if gt (len $method.Returns) 0}}
{{- range $retIndex, $ret := $method.Returns}}
{{- if eq $retIndex (sub (len $method.Returns) 1)}}
---@return {{.Type}}{{if ne .Comment ""}} #{{truncateComment .Comment 80}}{{end}}
{{- else}}
---@return {{.Type}}{{if ne .Comment ""}} #{{truncateComment .Comment 80}}{{end}}
{{- end}}
{{- end}}
{{.Name}} = function(self{{if gt (len .Params) 0}}, {{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param.Name}}{{end}}{{end}}) end,
{{- else}}
{{.Name}} = function(self{{if gt (len .Params) 0}}, {{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param.Name}}{{end}}{{end}}) end,
{{- end}}
{{- if ne (plus1 $index) $n}}
{{- end}}
{{- end}}
}
{{- if gt (len .Constructors) 0}}
---@type {{$.ClassName}}
{{- range .Constructors}}
{{- range .Params}}
{{- if ne .Comment ""}}
---{{.Name}} ({{.Type}}) -> {{.Comment}}
{{- end}}
{{- end}}
---@overload fun({{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param.Name}}: {{$param.Type}}{{end}}): {{$.ClassName}}{{- if ne .Comment ""}}
---{{.Comment}}
---@overload fun({{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param.Name}}: {{$param.Type}}{{end}}): {{$.ClassName}}
{{- end}}
{{- end}}
{{.ClassName}} = nil