Refine the template to fix excessive newlines

This commit is contained in:
2024-09-12 00:40:20 +02:00
parent 2e10e11ab9
commit 440a6e33e6
4 changed files with 67 additions and 22 deletions

View File

@@ -1,23 +1,22 @@
---@diagnostic disable: missing-return
{{range .Fields}}
{{range .Fields -}}
---@field {{.Name}} {{.Type}} {{.Comment}}
{{end}}
{{.ClassName}} = {
{{$n := len .Methods}}
{{$methods := len .Methods}}
{{range $index, $method := .Methods}}
{{$n := len .Methods -}}
{{$methods := len .Methods -}}
{{range $index, $method := .Methods -}}
---@param self {{$.ClassName}}
{{range $param := $method.Params}}
{{range $param := $method.Params -}}
---@param {{.Name}} {{.Type}} {{.Comment}}
{{end}}
{{range $ret := $method.Returns}}
{{end -}}
{{range $ret := $method.Returns -}}
---@return {{.Type}} {{if ne .Comment ""}}#{{.Comment}}{{end}}
{{end}}
{{end -}}
{{.Name}} = function(self{{if gt (len .Params) 0}}, {{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param.Name}}{{end}}{{end}}) end,
{{if eq (plus1 $index) $n}}
{{- if ne (plus1 $index) $n}}
{{end}}
{{end}}
{{end}}{{end}}
}
---@type ({{$.ClassName}} | fun(): {{$.ClassName}})