Add new hook for running terraform-docs which will replace content of README.md (using Python)#27
Add new hook for running terraform-docs which will replace content of README.md (using Python)#27antonbabenko merged 5 commits intoantonbabenko:masterfrom RothAndrew:feature/new_hook
Conversation
antonbabenko
left a comment
There was a problem hiding this comment.
Thanks for the PR. It looks pretty good, but I propose to make few customization to make it more flexible:
- Make filename
README.mdcustomizable via args. - Where
main.tfcomes from? Where it is used? Whymain.tf? - Move
setup.pyand package files inside a folder (eg,terraform_docs_replace) to not mix root of the repo. sedcommand can be different between systems. Since this is already in Python I would recommend to use native Python methods and replacesed.
Sure that sounds reasonable.
main.tf is the standard entrypoint for a Terraform module.
According to the docs setup.py has to stay at the root in order to get picked up by pip. Note: a single setup.py file will support any and all future pre-commit hooks written in Python. All you have to do is add a line to the
Makes sense |
|
Looks good. :) Could you also add a note to README for developers (not users) something like "It is possible to support any and all future pre-commit hooks written in Python. All you have to do is add a line to the console_scripts array in entry_points." |
|
Don't merge this yet. I'm not done with it. |
|
Actually, maybe I am. @antonbabenko if you're fine with leaving the call to |
|
Ready to merge. I'm done making changes unless there are more requested. |
|
Great! v1.8.0 has been released. Thanks @RothAndrew for the work! |
This is not clear - could you update the docs to explain this, @RothAndrew ? |
Adds a new hook called
terraform_docs_replacewhich uses the documentation found at the top ofmain.tfto recreate README.md. I'm open to suggestions on the name, I don't love it.Fix #17
I know this is going to probably come across as "going against the grain" a little bit, but I wanted to write it because this is how I've done all my Terraform documentation, and this seemed like the right place for it to live.
It's not super thoroughly tested, but from the testing that I have done it looks very promising. Switching to Python instead of a shell script actually gives better OS compatibility because it works anywhere Python works vs the bash scripts that only work on OS's in the Unix family. Also, we know Python is already installed because you need Python to run
pre-commit