Add one extra special variable the `content`:
- `{{ .Module }}`
As opposed to the other variables, which are generated sections based on
a selected formatter, the `{{ .Module }}` variable is just a `struct`
representing a Terraform module.
It can be used to build highly complex and highly customized content:
```yaml
content: |-
## Resources
{{ range .Module.Resources }}
- {{ .GetMode }}.{{ .Spec }} ({{ .Position.Filename }}#{{ .Position.Line }})
{{- end }}
```
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
If terraform-docs is being used as a library, `print.ReadConfig()` can
be used to dynamically read and load .terraform-docs.yml config file.
Example:
```go
config, err := print.ReadConfig(".", ".terraform-docs.yml")
if err != nil {
...
}
```
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
Up to now there was only one way to enable recursive execution and that
was with `--recursive` CLI flag. This enables the same behavior but
within config file (i.e. `.terraform-docs.yml`)
Example:
```yaml
recursive:
enabled: false
path: modules
```
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
Terraform implies a variable being required if you don't specify a default value, see [1].
Only if you leave out a default value the above "Required" column becomes a meaning.
The reality is, we specify a lot of default values for variables that are indeed required
but for whom we provide a sane default.
Furthermore we also specify quite some default empty string values "" for variables
which indeed are required, but we still cannot leave them out to mark them as required,
because of limitations in terraform where those values are being used in ternary operators.
Therefore the "Required" markdown column is meaningless in a lot of use
cases. This fixes it by introducing a `--no-required` option for markdown
generation which simply does not print it. It defaults to
false to retain current functionality.
[1] https://www.terraform.io/intro/getting-started/variables.html#defining-variables
Converting all line breaks into HTML doesn't make for good looking
tables. :P
This now converts all double line breaks into double break tags, but
then converts any remaining line breaks to spaces.
Tables in Markdown don't render line breaks properly, causing broken
table rendering when there are newlines in descriptions. This ensures
that the Markdown renderer replaces all newlines in descriptions with
HTML line breaks.