Tweak adoc templates
- Updates path for generated docs - Adds adoc codegen for expression and fixes expr_types.gen.adoc.tpl
This commit is contained in:
@@ -216,3 +216,17 @@ func genAutomationFunctions(tpl *template.Template, dd ...*aFuncDefs) (err error
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// genAutomationFunctionDocs look for afunc.gen.adoc.tpl and generates afunc.gen.adoc from it
|
||||
func genAutomationFunctionDocs(tpl *template.Template, docsPath string, dd ...*aFuncDefs) (err error) {
|
||||
var (
|
||||
typeGenAdoc = tpl.Lookup("afunc.gen.adoc.tpl")
|
||||
|
||||
dst string
|
||||
)
|
||||
|
||||
dst = path.Join(docsPath, "afunc.gen.adoc")
|
||||
return plainTemplate(dst, typeGenAdoc, map[string]interface{}{
|
||||
"Definitions": dd,
|
||||
})
|
||||
}
|
||||
|
||||
63
pkg/codegen/assets/afunc.gen.adoc.tpl
Normal file
63
pkg/codegen/assets/afunc.gen.adoc.tpl
Normal file
@@ -0,0 +1,63 @@
|
||||
// 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:
|
||||
{{- range .Definitions }}
|
||||
// - {{ .Source }}
|
||||
{{- end }}
|
||||
|
||||
{{ range $d := .Definitions }}
|
||||
= `{{ $d.Name }}`
|
||||
|
||||
[cols="2m,4a,3a"]
|
||||
|===
|
||||
| Name | Description | I/O
|
||||
|
||||
{{- range $f := .Functions }}
|
||||
|
||||
{{- if eq $f.Kind "function" }}
|
||||
|
||||
| [#fnc-{{ toLower $d.Name }}-{{ toLower $f.Name }}]#<<fnc-{{ toLower $d.Name }}-{{ toLower $f.Name }},{{ if $f.Meta.Short }}{{ $f.Meta.Short }}{{ else }}{{ $f.Name }}{{ end }}>>#
|
||||
| {{ if $f.Meta.Description }}{{ $f.Meta.Description }}{{ end }}
|
||||
|
|
||||
{{- if gt (len $f.Params) 0}}
|
||||
.Parameters:
|
||||
{{- range $p := $f.Params}}
|
||||
* {{ if $p.Required }}#*# {{ end }}`{{ if $p.Meta }}
|
||||
{{- if $p.Meta.Label }}
|
||||
{{- $p.Meta.Label }}
|
||||
{{- else }}
|
||||
{{- $p.Name }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $p.Name }}
|
||||
{{- end }}`
|
||||
({{- range $pti, $pt := $p.Types }}
|
||||
`{{- $pt.WorkflowType }}`,
|
||||
{{- end }})
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if gt (len $f.Results) 0}}
|
||||
|
||||
.Results:
|
||||
{{- range $r := $f.Results}}
|
||||
* {{ if $r.Meta }}
|
||||
{{- if $r.Meta.Label }}
|
||||
{{- $r.Meta.Label }}
|
||||
{{- else }}
|
||||
{{- $r.Name }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $r.Name }}
|
||||
{{- end }} (`{{ $r.WorkflowType }}`)
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|===
|
||||
{{- end }}
|
||||
32
pkg/codegen/assets/expr_types.gen.adoc.tpl
Normal file
32
pkg/codegen/assets/expr_types.gen.adoc.tpl
Normal file
@@ -0,0 +1,32 @@
|
||||
// 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:
|
||||
{{- range .Definitions }}
|
||||
// - {{ .Source }}
|
||||
{{- end }}
|
||||
|
||||
[cols="2m,3a"]
|
||||
|===
|
||||
| Type | Structure
|
||||
{{- range .Definitions }}
|
||||
{{- range $tName, $tDef := .Types }}
|
||||
{{- if gt (len $tDef.Struct) 0}}
|
||||
| [#objref-{{ toLower $tName }}]#<<objref-{{ toLower $tName }},{{ $tName }}>>#
|
||||
|
|
||||
{{- if $tDef.Struct }}
|
||||
[source]
|
||||
----
|
||||
{
|
||||
{{- range $s := .Struct }}
|
||||
{{ $s.Name }} ({{ $s.ExprType }})
|
||||
{{- end }}
|
||||
}
|
||||
----
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
|===
|
||||
@@ -7,6 +7,7 @@
|
||||
{{- range .Definitions }}
|
||||
// - {{ .Source }}
|
||||
{{- end }}
|
||||
include::ROOT:partial$variables.adoc[]
|
||||
|
||||
{{ range .Definitions }}
|
||||
= {{ .Docs.Title }}
|
||||
@@ -24,7 +25,10 @@
|
||||
{{ if .Default -}}
|
||||
=== Default
|
||||
|
||||
`{{ .Default }}`
|
||||
[source]
|
||||
----
|
||||
{{ .Default }}
|
||||
----
|
||||
|
||||
{{ end -}}
|
||||
{{ if .Description -}}
|
||||
|
||||
10
pkg/codegen/codegen.go
generated
10
pkg/codegen/codegen.go
generated
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
func Proc() {
|
||||
const (
|
||||
docGenBase = "/partials/generated"
|
||||
docGenBase = "/generated/partials"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -129,7 +129,7 @@ func Proc() {
|
||||
}()
|
||||
|
||||
if len(docPath) > 0 {
|
||||
docPath = strings.TrimRight(docPath, "/") + "/src/modules/ROOT"
|
||||
docPath = strings.TrimRight(docPath, "/") + "/src/modules"
|
||||
if i, err := os.Stat(docPath); err != nil {
|
||||
handleError(err)
|
||||
} else if !i.IsDir() {
|
||||
@@ -212,6 +212,9 @@ func Proc() {
|
||||
if genCode {
|
||||
err = genExprTypes(tpls, exprTypeDefs...)
|
||||
}
|
||||
if genDocs && err == nil {
|
||||
err = genExprTypeDocs(tpls, docPath+docGenBase, exprTypeDefs...)
|
||||
}
|
||||
}
|
||||
|
||||
if outputErr(err, "failed to process expr types:\n") {
|
||||
@@ -282,6 +285,9 @@ func Proc() {
|
||||
|
||||
err = genAutomationFunctions(tpls, aFuncsDefs...)
|
||||
}
|
||||
if genDocs && err == nil {
|
||||
err = genAutomationFunctionDocs(tpls, docPath+docGenBase, aFuncsDefs...)
|
||||
}
|
||||
}
|
||||
|
||||
if outputErr(err, "failed to process automation functions:\n") {
|
||||
|
||||
@@ -109,6 +109,20 @@ func genExprTypes(tpl *template.Template, dd ...*exprTypesDef) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// genExprTypeDocs look for expr_types.gen.adoc.tpl and generates expr_types.gen.adoc from it
|
||||
func genExprTypeDocs(tpl *template.Template, docsPath string, dd ...*exprTypesDef) (err error) {
|
||||
var (
|
||||
typeGenAdoc = tpl.Lookup("expr_types.gen.adoc.tpl")
|
||||
|
||||
dst string
|
||||
)
|
||||
|
||||
dst = path.Join(docsPath, "expr-types.gen.adoc")
|
||||
return plainTemplate(dst, typeGenAdoc, map[string]interface{}{
|
||||
"Definitions": dd,
|
||||
})
|
||||
}
|
||||
|
||||
func (s exprTypeDef) Default() string {
|
||||
if s.RawDefault == "" {
|
||||
return "nil"
|
||||
|
||||
Reference in New Issue
Block a user