3
0

Add options.gen.adoc.tpl, modify options.go to enable .adoc codegen from .gen.adoc.tpl

This commit is contained in:
Urban Klinc
2020-12-02 10:44:01 +01:00
parent 988291f938
commit 595d929e89
2 changed files with 44 additions and 4 deletions

View File

@@ -0,0 +1,23 @@
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// {{ .Source }}
= {{ export $.Name }}
[cols="2,3,5a"]
|===
|Type|Default value|Description
{{- range $prop := $.Properties }}
3+| *{{ toUpper $prop.Env }}*
|`{{ $prop.Type }}`
|{{- if $prop.Default }}
{{- $prop.Default -}}
{{- end -}}
|{{ $prop.Description }}
{{- end }}
|===

View File

@@ -28,10 +28,11 @@ type (
optionsPropSet []*optionsProp
optionsProp struct {
Name string
Type string
Env string
Default *optionsPropDefault
Name string
Type string
Env string
Default *optionsPropDefault
Description string
}
optionsPropDefault string
@@ -108,6 +109,8 @@ func genOptions(tpl *template.Template, dd ...*optionsDef) (err error) {
var (
tplOptionsGen = tpl.Lookup("options.gen.go.tpl")
tplOptionsAdoc = tpl.Lookup("options.gen.adoc.tpl")
dst string
)
@@ -117,6 +120,20 @@ func genOptions(tpl *template.Template, dd ...*optionsDef) (err error) {
if err != nil {
return
}
dst = path.Join(d.outputDir, path.Base(d.Source)[:strings.LastIndex(path.Base(d.Source), ".")]+".adoc")
err = goTemplate(dst, tplOptionsAdoc, d)
if err != nil {
return
}
}
// for _, d := range dd {
// dst = path.Join(d.outputDir, path.Base(d.Source)[:strings.LastIndex(path.Base(d.Source), ".")]+".adoc")
// err = goTemplate(dst, tplOptionsAdoc, d)
// if err != nil {
// return
// }
// }
return nil
}