mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
Add new hook for running terraform-docs with replacing README.md from doc in main.tf
This commit is contained in:
parent
7acd99eeb7
commit
9aa971c069
6 changed files with 102 additions and 40 deletions
10
README.md
10
README.md
|
|
@ -52,6 +52,7 @@ There are several [pre-commit](http://pre-commit.com/) hooks to keep Terraform c
|
|||
* `terraform_validate_with_variables` - Validates all Terraform configuration files and checks whether all required variables were specified.
|
||||
* `terraform_docs` - Inserts input and output documentation into `README.md`. Recommended.
|
||||
* `terraform_docs_without_aggregate_type_defaults` - Inserts input and output documentation into `README.md` without aggregate type defaults.
|
||||
* `terraform_docs_replace` - Runs `terraform-docs` and pipes the output directly to README.md
|
||||
|
||||
Check the [source file](https://github.com/antonbabenko/pre-commit-terraform/blob/master/.pre-commit-hooks.yaml) to know arguments used for each hook.
|
||||
|
||||
|
|
@ -61,6 +62,15 @@ Check the [source file](https://github.com/antonbabenko/pre-commit-terraform/blo
|
|||
|
||||
1. `terraform_docs` and `terraform_docs_without_aggregate_type_defaults` will insert/update documentation generated by [terraform-docs](https://github.com/segmentio/terraform-docs) between markers - `<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->` and `<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->` if they are present in `README.md`. Make sure that `terraform-docs` is installed.
|
||||
|
||||
1. `terraform_docs_replace` replaces the entire README.md rather than doing string replacement between markers. Put your additional documentation at the top of your `main.tf` for it to be pulled in.
|
||||
|
||||
1. Example:
|
||||
```yaml
|
||||
hooks:
|
||||
- id: terraform_docs_replace
|
||||
args: ['--with-aggregate-type-defaults', '--sort-inputs-by-required']
|
||||
```
|
||||
|
||||
1. It is possible to pass additional arguments to shell scripts when using `terraform_docs` and `terraform_docs_without_aggregate_type_defaults`. Send pull-request with the new hook if there is something missing.
|
||||
|
||||
Enjoy the clean and documented code!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue