This hook leverages the excellent https://github.com/segmentio/terraform-docs and its dockerized version https://github.com/cytopia/docker-terraform-docs to automatically update README files for every commit.
Either copy this hook into .git/hooks/
or into a custom directory.
If you opt for the latest option, run the below command to add it to your local .gitconfig
.
# Example with a hook dir .githooks/
git config --local core.hooksPath .githooks
Example of working directory structure parsed by the hook:
$ tree
.
|-- main.tf
|-- modules
| |-- module
| |-- main.tf
| |-- variables.tf
|-- README.md
|-- variables.tf
A README.md file is fully auto-generated for every modules found in modules/
.
A header can optionally be created by adding the below snippet at the beginning of modules/module/main.tf
:
/**
* # Main title
*
* Other markdown-friendly content.
*/
In addition, the main README.md located at the root of your project will be partially generated if it contains the following pair of tags:
<\!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Enjoy!