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

Document how to emit attribute defaults (and other customizations) via the SDK

Open jbristowe opened this issue 5 years ago • 1 comments

Assume the following schema segment:

"quantity": {
  Default:  30,
  Description: "The quantity of this resource.",
  Optional: true,
  Type:     schema.TypeInt,
}

When documentation is generated, fields are emitted with their type and a requirement "indicator":

quantity (Number, Optional) The quantity of this resource.

A default value should be emitted to the generated Markdown if specified in the underlying schema:

quantity (Number, Optional, Default: 30) The quantity of this resource.

jbristowe avatar Dec 03 '20 00:12 jbristowe

I mentioned something similar in another issue, but this exists, its just implemented on the SDK side, see this example in the scaffolding repo: https://github.com/hashicorp/terraform-provider-scaffolding/blob/bec212504f3fc7ad42e5f3a80425cb95872dda28/internal/provider/provider.go#L15-L23

I'm going to leave this open as a documentation issue, as we should clarify for folks how to do these things.

paultyng avatar Jan 26 '21 17:01 paultyng