-
Notifications
You must be signed in to change notification settings - Fork 77
Description
Terraform CLI and terraform-plugin-docs Versions
N/A - terraform-plugin-docs v0.22.0
Use Cases or Problem Statement
Provider developers may wish to include multiple resource examples in their documentation. The current default resource template will only look for the conventional examples/resources/NAME/resource.tf
file. To implement multiple examples, a custom template and all its implementation details must be understood, written, and maintained.
Proposal
It would be awesome if the logic before the templating could detect multiple example files via glob matching, e.g. examples/resources/NAME/resource*.tf
, then pass that array of example files to the template to for/range over with tffile
:
{{ if .HasExamples -}}
## Example Usage
{{- range .ExampleFiles }}
{{ tffile . }}
{{- end }}
{{- end }}
This could also be done for data-source*.tf
, etc. for the other documentation default templates.
I don't believe this would have any negative compatibility concerns since the current file lookup logic is hardcoded and if you were to already have a custom template, the default template doing this new behavior would have no effect. The existing HasExample
(singular) and ExampleFile
(singular) fields can be left for backwards compatibility of existing templates.
How much impact is this issue causing?
Medium
Additional Information
No response
Code of Conduct
- I agree to follow this project's Code of Conduct