Customize content with individual sections output

Generated content can be customized further away with `content` in configuration.
If the `content` is empty the default orders of section is used. `content` is a
Go template with following additional variables:

- `{{ .Header }}`
- `{{ .Footer }}`
- `{{ .Inputs }}`
- `{{ .Modules }}`
- `{{ .Outputs }}`
- `{{ .Providers }}`
- `{{ .Requirements }}`
- `{{ .Resources }}`

```yaml
content: |-
  Any arbitrary text can be placed anywhere in the content

  {{ .Header }}

  and even in between sections

  {{ .Providers }}

  and they don't even need to be in the default order

  {{ .Outputs }}

  {{ .Inputs }}
```

These variables are the generated output of individual sections in the selected
formatter. For example `{{ .Inputs }}` is Markdown Table representation of inputs
when formatter is set to `markdown table` and AsciiDoc Document representation
when formatter is set to `asciidoc document` and so on.

Compatible formats for customized content are:

- `asciidoc document`
- `asciidoc table`
- `markdown document`
- `markdown table`

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
This commit is contained in:
Khosrow Moossavi
2021-05-10 18:23:09 -04:00
parent 4fd410b954
commit 6777364257
71 changed files with 1425 additions and 723 deletions

View File

@@ -185,7 +185,7 @@ func example(ref *reference) error {
},
}
printer, err := format.Factory(ref.Name, settings)
formatter, err := format.Factory(ref.Name, settings)
if err != nil {
return err
}
@@ -195,7 +195,11 @@ func example(ref *reference) error {
log.Fatal(err)
}
output, err := printer.Print(tfmodule, settings)
generator, err := formatter.Generate(tfmodule)
if err != nil {
return err
}
output, err := generator.ExecuteTemplate("")
if err != nil {
return err
}