terraform-plugin-docs
terraform-plugin-docs copied to clipboard
Document how to emit attribute defaults (and other customizations) via the SDK
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.
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.