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

Allow setting subcategory from code

Open fbreckle opened this issue 3 years ago • 5 comments

Hi,

per the docs, subcategories can be used to add some structure to the docs. The default template defaults to "", which I could then manually adjust.

The problem with this is this: I maintain a provider with many external contributions are via pull requests. We have a pipeline that enforces that the documentation is updated by running tfplugindocs on the PR and then erroring if there are any changes. This means the author of the PR themselves must run tfplugindocs if they introduce a new attribute or resource to update the docs in their PR.

This means managing the subcategory manually is not an option.

fbreckle avatar Jun 22 '22 07:06 fbreckle

How can we help support this feature ?

kwent avatar Aug 12 '22 11:08 kwent

I actually recently implemented this in a fork of this repo at https://github.com/fbreckle/terraform-plugin-docs In that fork, you can add metadata to the description attribute, which will then set the subcategory in the template. The metadata will then be stripped when creating the documentation. You can see this implemented in https://github.com/e-breuninger/terraform-provider-netbox/commit/1d1196aee999fa2f2e2de298aaecf88c914cdf1f#diff-298869f21140588fa6fe0a0810d47e429d22d189e570606afb73ea7f2905d293

I find this approach invasive enough that I did not make a PR in in this repo, though if the maintainers of this repo are interested, I can surely create a merge request.

fbreckle avatar Aug 12 '22 12:08 fbreckle