Add options.gen.adoc.tpl, modify options.go to enable .adoc codegen from .gen.adoc.tpl
This commit is contained in:
23
pkg/codegen/assets/options.gen.adoc.tpl
Normal file
23
pkg/codegen/assets/options.gen.adoc.tpl
Normal 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 }}
|
||||
|===
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user