Code polish

This commit is contained in:
2024-09-15 18:17:57 +02:00
parent ff36d5a6e9
commit 0f32c49569
2 changed files with 9 additions and 8 deletions

View File

@@ -11,6 +11,7 @@ import (
"text/template"
"github.com/PuerkitoBio/goquery"
"github.com/davecgh/go-spew/spew"
)
//go:embed class.tmpl
@@ -90,7 +91,7 @@ func (c *Class) Write(root string, tmpl *template.Template) error {
if err != nil {
return fmt.Errorf("error creating output file %v: %v", c.ClassName, err)
}
// spew.Dump(c)
spew.Dump(c)
err = tmpl.Execute(outfile, c)
if err != nil {
return fmt.Errorf("error writing output file %v: %v", c.ClassName, err)
@@ -128,10 +129,10 @@ func ParseClass(file string) (*Class, error) {
res.ClassName = className
classDescription, err := getClassDescription(dataContainer)
if err != nil {
return nil, fmt.Errorf("error getting class description: %w", err)
if err == nil {
// return nil, fmt.Errorf("error getting class description: %w", err)
res.Description = classDescription
}
res.Description = classDescription
constructor, err := getConstructor(dataContainer)
if err != nil {

View File

@@ -1,6 +1,6 @@
---@diagnostic disable: missing-return, lowercase-global
---@class {{.ClassName}}
---{{.Description}}
---@class {{.ClassName}}{{if ne .Description ""}}
---{{.Description}}{{end}}
{{- range .Fields}}
---@field {{.Name}} {{.Type}}{{if ne .Comment ""}} {{.Comment}}{{end}}
{{- end}}
@@ -16,8 +16,8 @@
{{- end}}{{if ne .Comment ""}}
---{{.Comment}}{{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}}
{{- if ne (plus1 $index) $n}}
{{end}}
{{- end}}
}