Update logger and other packages
This commit is contained in:
15
class.go
15
class.go
@@ -3,14 +3,13 @@ package main
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
logger "git.site.quack-lab.dev/dave/cylogger"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
)
|
||||
|
||||
//go:embed class.tmpl
|
||||
@@ -27,7 +26,7 @@ func init() {
|
||||
var err error
|
||||
classTemplate, err = template.New("class").Funcs(fns).Parse(templatestr)
|
||||
if err != nil {
|
||||
Error.Printf("Error parsing template: %v", err)
|
||||
logger.Error("Error parsing template: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -96,7 +95,8 @@ func (c *Class) Write(root string, tmpl *template.Template) error {
|
||||
}
|
||||
|
||||
func ParseClass(file string) (*Class, error) {
|
||||
log.Printf("Parsing file: '%s'", file)
|
||||
log := logger.Default.WithPrefix(file)
|
||||
log.Info("Parsing file")
|
||||
res := Class{
|
||||
Fields: []Field{},
|
||||
Methods: []Method{},
|
||||
@@ -134,7 +134,7 @@ func ParseClass(file string) (*Class, error) {
|
||||
return nil, fmt.Errorf("error getting methods: %w", err)
|
||||
}
|
||||
|
||||
// spew.Dump(res)
|
||||
log.Info("Parsing complete")
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ func getConstructors(doc *goquery.Document) ([]Constructor, error) {
|
||||
resConstructor.Comment = strings.TrimSpace(resConstructor.Comment)
|
||||
})
|
||||
|
||||
spew.Dump(resConstructor)
|
||||
logger.Dump("resConstructor", resConstructor)
|
||||
return append(res, resConstructor), nil
|
||||
}
|
||||
|
||||
@@ -226,6 +226,9 @@ func getMethods(doc *goquery.Document) ([]Method, error) {
|
||||
types.Each(func(i int, s *goquery.Selection) {
|
||||
param := Param{}
|
||||
param.Name = strings.TrimSpace(parameters.Eq(i).Text())
|
||||
if IsReservedKeyword(param.Name) {
|
||||
param.Name = fmt.Sprintf("__%s", param.Name)
|
||||
}
|
||||
param.Type = strings.TrimSpace(types.Eq(i).Text())
|
||||
param.Type = MapType(param.Type)
|
||||
method.Params = append(method.Params, param)
|
||||
|
||||
Reference in New Issue
Block a user