Configuration can be loaded with `-c, --config string` which accepts
both relative and absolute paths.
$ pwd
/path/to/parent/folder
$ tree
.
├── module-a
│ └── main.tf
├── module-b
│ └── main.tf
├── ...
└── .terraform-docs.yml
# executing from parent
$ terraform-docs -c .terraform-docs.yml module-a/
# executing from child
$ cd module-a/
$ terraform-docs -c ../.terraform-docs.yml .
# or an absolute path
$ terraform-docs -c /path/to/parent/folder/.terraform-docs.yml .
The order for looking for config file is:
1. root of module directory
2. current directory
3. `$HOME/.tfdocs.d/`
if `.terraform-docs.yml` is found in any of the folders above, that will
take precedence and will override the other ones. Note that values passed
directly as CLI flags will override all of the above.
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
The following scenarios can happen for --output-mode inject:
- file exists, comments exist: inject output between comments
- file exists, comments not found: append output at the end of file
- file exists, but empty: save the whole output into the file
- file not found: create the target file and save the ooutput into it
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
Template is optional when writing to --output-file and --output-mode is
'replace'. This is useful in particular when user wants to directly
output to a known file format, for example json, yaml, in which
sourrounding comments will break linters or functionality of those
formats.
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
There are two modes for saving into file:
- inject: partially replace the target file with generated output
- replace: completely replace the target file with generated output
The output generated by formatters (markdown, asciidoc, etc) will be
inserted into a template before getting saved into the file. This
template can be customized with '--output-template' CLI flag or
corresponding item in '.terraform-docs.yml' config file. Its default
value is:
```
<!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS -->
```
This consists of three items, all of them are mandatory:
- begin comment
- content variable
- end comment
You may change the wording of comment as you wish, but the comment must
be present in the template.
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>