-
-
Notifications
You must be signed in to change notification settings - Fork 544
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
feat(terraform_docs
): Add support for custom markers to better support other formats than Markdown
#752
base: master
Are you sure you want to change the base?
Conversation
… other formats than markdown
895c3fe
to
c6065ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. Please have a look into comments I added.
I'd also think of adding this as a single configuration parameter to avoid use of mix of standard and custom markers. Something like --custom-markers="// BEGIN;// END"
. This may decrease clarity and readability and separator needs a more thorough think though.
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. @MaxymVlasov What do you think?
terraform_docs
): Add support for custom markers to better support other formats than Markdown
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #752 +/- ##
===========================================
- Coverage 100.00% 96.38% -3.62%
===========================================
Files 9 10 +1
Lines 161 249 +88
Branches 5 7 +2
===========================================
+ Hits 161 240 +79
- Misses 0 9 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Co-authored-by: Maksym Vlasov <[email protected]>
Hmm, you probably had
|
Also, I found that formatter: asciidoc table
output:
file: README.adoc
mode: inject
template: |-
// BEGIN_TF_DOCS
{{ .Content }}
// END_TF_DOCS repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: fc53d0a10b7846fa8571ddd504660cbe5c6110d6
- id: terraform_docs
args:
- --hook-config=--add-to-existing-file=true # Boolean. true or false
#- --hook-config=--custom-marker-begin=// BEGIN_TF_DOCS
#- --hook-config=--custom-marker-end=// END_TF_DOCS When you have empty And it produces identical result as for Can you please elaborate on what exactly you tried to fix/add by this PR? |
If you got a non-empty file, it won't work for me without the custom markers.
With this snippet in an existing file, I won't get any output with the latest release/master.
This will result in:
This also works if you only have a begin marker, as it is the only thing the grep looks for. |
I see what you're talking about Interesting, that specified by you example of
work well with formatter: asciidoc table
output:
file: README.adoc
mode: inject
template: |-
// BEGIN_TF_DOCS
{{ .Content }}
// END_TF_DOCS repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.96.3
hooks:
- id: terraform_docs
args:
- --hook-config=--add-to-existing-file=true # Boolean. true or false
- --args=--config=.terraform-docs.yml but not with and args:
- --hook-config=--create-file-if-not-exist=true # Boolean. true or false
- --args=--config=.terraform-docs.yml produce
So if If you have time, please investigate what happens, using |
You could try to parse the template in the config, grab the first line of it, check if it is not |
Am I right that you anyway need to specify So, we actually need to find all |
Yeah, it is set up defaulting to Markdown and HTML comments, but there would be other options in MD as well. If you run it like it was |
Ah, yes. And parse it from Just let make file creation header ( pre-commit-terraform/hooks/terraform_docs.sh Lines 199 to 204 in e01b4de
as
will be annoying to fix. So, let's reiterate on same question but for different use-case - can we just get header data from |
I think Another way could be just, letting terraform-docs create the file would be an option as well, which should work if there is a |
Please add
Interesting solution, but let someone comes with feature request, as I don't see who could use it :) |
Put an
x
into the box if that apply:Description of your changes
This adds support to pass custom markers.
This helps to improve support for other formats like asciidoc which you can use if you use a config for terraform-doc.
How can we test changes
Add your custom marker to a README and run the hook with the options. You may also want to change the template used by terraform-doc