diff --git a/class.go b/class.go index d10d09f..e3bb131 100644 --- a/class.go +++ b/class.go @@ -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 { diff --git a/class.tmpl b/class.tmpl index 2c69178..28c94ba 100644 --- a/class.tmpl +++ b/class.tmpl @@ -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}} }