Files
avorion-docgen/class.tmpl

35 lines
1.2 KiB
Cheetah

---@diagnostic disable: missing-return, lowercase-global
---@class {{.ClassName}}
{{- range .Fields}}
---@field {{.Name}} {{.Type}}{{if ne .Comment ""}} {{.Comment}}{{end}}
{{- end}}
{{.ClassName}} = {
{{- $n := len .Methods}}
{{- range $index, $method := .Methods}}
---@param self {{$.ClassName}}
{{- range $param := $method.Params}}
---@param {{.Name}} {{.Type}}{{if ne .Comment ""}} {{.Comment}}{{end}}
{{- end}}
{{- range $ret := $method.Returns}}
---@return {{.Type}}{{if ne .Comment ""}} #{{.Comment}}{{end}}
{{- end}}
{{.Name}} = function(self{{if gt (len .Params) 0}}, {{range $index, $param := .Params}}{{if $index}}, {{end}}{{$param.Name}}{{end}}{{end}}) end,
{{- if ne (plus1 $index) $n}}
{{- end}}
{{- end}}
}
---@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}}
{{- end}}
{{- end}}
{{.ClassName}} = nil
-- Define class globally so it's "available" to other files