Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ require (
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e // indirect
github.com/google/renameio/v2 v2.0.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/gosimple/slug v1.15.0 // indirect
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/grid-x/serial v0.0.0-20211107191517-583c7356b3aa // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWS
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gosimple/slug v1.15.0 h1:wRZHsRrRcs6b0XnxMUBM6WK1U1Vg5B0R7VkIf1Xzobo=
github.com/gosimple/slug v1.15.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ=
github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o=
github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc=
github.com/gregdel/pushover v1.3.1 h1:4bMLITOZ15+Zpi6qqoGqOPuVHCwSUvMCgVnN5Xhilfo=
github.com/gregdel/pushover v1.3.1/go.mod h1:EcaO66Nn1StkpEm1iKtBTV3d2A16SoMsVER1PthX7to=
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA=
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/charger/ocpp-abb-tac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ covers: ["ocpp-abb"]
products:
- brand: ABB
description:
generic: Terra AC
generic: Terra AC (OCPP)
capabilities: ["mA", "rfid"]
requirements:
evcc: ["sponsorship", "skiptest"]
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/charger/ocpp-alfen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ template: ocpp-alfen
products:
- brand: Alfen
description:
generic: Eve
generic: Eve (OCPP)
capabilities: ["mA", "rfid", "1p3p"]
requirements:
evcc: ["sponsorship", "skiptest"]
Expand Down
8 changes: 4 additions & 4 deletions templates/definition/charger/ocpp-goe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ covers: ["ocpp-fronius-wattpilot"]
products:
- brand: go-e
description:
generic: Charger V3
generic: Charger V3 (OCPP)
- brand: go-e
description:
generic: Charger Gemini
generic: Charger Gemini (OCPP)
- brand: go-e
description:
generic: Charger PRO
generic: Charger PRO (OCPP)
- brand: Fronius
description:
generic: Wattpilot
generic: Wattpilot (OCPP)
capabilities: ["rfid", "1p3p"]
requirements:
evcc: ["sponsorship", "skiptest"]
Expand Down
2 changes: 1 addition & 1 deletion templates/definition/charger/ocpp-zaptec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ template: ocpp-zaptec
products:
- brand: Zaptec
description:
generic: Go
generic: Go (OCPP)
Comment thread
andig marked this conversation as resolved.
capabilities: ["rfid"]
requirements:
description:
Expand Down
1 change: 1 addition & 0 deletions util/templates/documentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (t *Template) RenderDocumentation(product Product, lang string) ([]byte, er

data := map[string]interface{}{
"Template": t.Template,
"ProductIdentifier": product.Identifier(),
"ProductBrand": product.Brand,
"ProductDescription": product.Description.String(lang),
"ProductGroup": t.GroupTitle(lang),
Expand Down
30 changes: 30 additions & 0 deletions util/templates/documentation.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
{{- end }}
{{- end -}}

template: {{ .Template }}
product:
identifier: {{ .ProductIdentifier }}
{{- if .ProductBrand }}
brand: {{ .ProductBrand }}
{{- end }}
Expand Down Expand Up @@ -96,3 +98,31 @@ render:
{{- include "advanced" . | indent 4 }}
{{- end }}
{{- end }}
params:
{{- range .Params }}
{{- if and (not (eq .Name "usage")) (not .IsDeprecated) }}
- name: {{ .Name | quote }}
{{- if .Example }}
example: {{ .Example | quote }}
{{- end }}
{{- if .Default }}
default: {{ .Default }}
{{- end }}
{{- if .Choice }}
choice: [{{ join ", " .Choice }}]
{{- end }}
{{- if .Unit }}
unit: {{ .Unit }}
{{- end }}
{{- $description := localize .Description | replace "\n" " " }}
Comment thread
naltatis marked this conversation as resolved.
Outdated
{{- if $description }}
description: {{ $description | quote }}
{{- end }}
{{- $help := localize .Help | replace "\n" " " }}
{{- if $help }}
help: {{ $help | quote }}
{{- end }}
advanced: {{ .IsAdvanced }}
optional: {{ not .IsRequired }}
{{- end }}
{{- end }}
9 changes: 7 additions & 2 deletions util/templates/generate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,20 @@ func generateClass(class templates.Class, lang string) error {
return err
}

for index, product := range tmpl.Products {
for _, product := range tmpl.Products {
fmt.Println(tmpl.Template + ": " + product.Title(lang))

b, err := tmpl.RenderDocumentation(product, lang)
if err != nil {
return err
}

filename := fmt.Sprintf("%s/%s/%s/%s_%d.yaml", docsPath, lang, strings.ToLower(class.String()), tmpl.Template, index)
filename := fmt.Sprintf("%s/%s/%s/%s.yaml", docsPath, lang, strings.ToLower(class.String()), product.Identifier())

if _, err := os.Stat(filename); err == nil {
return fmt.Errorf("file already exists: %s - product titles must be unique", filename)
}

if err := os.WriteFile(filename, b, 0o644); err != nil {
return err
}
Expand Down
8 changes: 8 additions & 0 deletions util/templates/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"

"dario.cat/mergo"
"github.com/gosimple/slug"
)

const (
Expand Down Expand Up @@ -259,10 +260,17 @@ type Product struct {
Description TextLanguage `json:",omitempty"` // product name
}

// Title returns the product title in the given language
func (p Product) Title(lang string) string {
return strings.TrimSpace(fmt.Sprintf("%s %s", p.Brand, p.Description.String(lang)))
}

// Identifier returns a unique language-independent identifier for the product
func (p Product) Identifier() string {
Comment thread
naltatis marked this conversation as resolved.
slug.CustomSub = map[string]string{"+": "plus"}
return slug.Make(p.Title("en"))
}

type CountryCode string

func (c CountryCode) IsValid() bool {
Expand Down
Loading