terraform-plugin-docs icon indicating copy to clipboard operation
terraform-plugin-docs copied to clipboard

Resource / Data source examples not detected when a template is provided

Open OJFord opened this issue 5 years ago • 2 comments

The readme describes using resource examples in examples/resources/<name>/resource.tf, but if I template {{ printf "%s" .ExampleFile }} it seems just to be "" for resources.

After a quick look at the code, I think it's just not implemented rather than a bug. I'm sure you know this - a note here just might help anyone else confused by it.

To workaround, you can of course just change the template to remove the if .HasExample and .ExampleFile and replace with a tffile "examples/resources/wherever.tf". That is:

{{/* templates/resources/name.md.tmpl */}}

 ## Example Usage

{{ tffile "examples/resources/name/resource.tf" }}

OJFord avatar Dec 01 '20 00:12 OJFord

Will need to investigate but I think this should be working so it may be an oversight at least if not a bug, going to mark it as a bug for now though since it was intended to work.

paultyng avatar Jan 26 '21 17:01 paultyng

The issue is real and a bit more generic: it has to do with the fact that the examples will not be picked up if a template for that resource/data source is detected.

detro avatar Mar 15 '22 13:03 detro