Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating docs for child modules #464

Closed
michelzanini opened this issue Apr 8, 2021 · 1 comment · Fixed by #548
Closed

Updating docs for child modules #464

michelzanini opened this issue Apr 8, 2021 · 1 comment · Fixed by #548

Comments

@michelzanini
Copy link

What problem are you facing?

I am using pre-commit with terraform-docs with the hook provided by https://github.com/antonbabenko/pre-commit-terraform.

On that hook, it's possible to update all README.md files, including sub-modules of the root module. But that does seem to work if I were to switch to use this repo's new pre-commit hooks.

For example, consider this structure:

.
├── README.md
├── main.tf
├── modules
│   └── my-sub-module
│       ├── README.md
│       ├── main.tf
│       ├── variables.tf
│       └── versions.tf
├── outputs.tf
├── variables.tf
└── versions.tf

As you can see I have a root README.md for the root Terraform module, but also one or more sub-modules with their own README.md files. It would be nice to be able to update them all with a single run of pre-commit at the root level of the project.

How could terraform-docs help solve your problem?

Be able to run pre-commit hook or terraform-docs standalone and update root module AND sub-modules as well. This could be potentially enabled via a flag, named something like --include-sub-modules, --recursive or something else...

@khos2ow khos2ow added this to Proposed in v0.15 via automation May 31, 2021
@khos2ow khos2ow moved this from Proposed to Accepted in v0.15 May 31, 2021
@khos2ow
Copy link
Member

khos2ow commented Jul 27, 2021

That's a really good suggestion. I like --recursive bool better, and to make it more flexible I like to add --recursive-path string (defaults to modules) to select submodules root folder.

That said, I'm not entirely sure this new feature can be used out of the box with antonbabenko/pre-commit-terraform right away due to different ways of saving the generated output to target files. Specifically the issue antonbabenko/pre-commit-terraform#179.

You can already use --output-file (and corresponding config) since v0.12.0, which will give us the ability to incorporate that with --recursive, but if you're not using terraform-docs' output and rely on pre-commit-terraform that means the --recursive needs to output to stdout and I cannot think of a reliable way pre-commit-terraform can pick up the output to inject (or replace) it in the correct submodule's target file (e.g. README.md).

@khos2ow khos2ow moved this from Accepted to PR Open in v0.15 Aug 9, 2021
v0.15 automation moved this from PR Open to Done Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v0.15
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants