Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate docs with go generator #201

Closed
displague opened this issue Dec 17, 2020 · 3 comments · Fixed by #645
Closed

Generate docs with go generator #201

displague opened this issue Dec 17, 2020 · 3 comments · Fixed by #645
Labels
documentation Improvements or additions to documentation enhancement New feature or request source/terraform-provider-metal This issue/pr was originally created in deprecated terraform-provider-metal repository
Milestone

Comments

@displague
Copy link
Member

displague commented Dec 17, 2020

It is now possible to generate provider docs using the https://www.terraform.io/docs/registry/providers/docs.html#generating-documentation generator and fields embedded in the provider.

Can we generate all of our documentation identically in this way?

The generator is noted to have some weakness handling deep structures.

Some example repositories using this method:

@displague displague added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 17, 2020
@t0mk
Copy link
Contributor

t0mk commented Dec 23, 2020

I have just tried tfplugindocs in this provider. It nicely generated all the markdown files to the docs/ dir.

However, to take full advantage of tfplugindocs (to have docs build on go generate from the repo root) we'd need to

  • copy description from our written docs to Description attr of each field of the resource schema
  • update terraform-plugin-sdk to (at least) newest 1x version, so that we can add Description field of schema.Resource for every resource (and I guess datasource too)
  • create examples/{data-sources,provider,resources} dirs with contents described in https://github.com/hashicorp/terraform-plugin-docs#conventional-paths
  • reformat all the examples from the current docs into files like e.g. examples/resources/metal_device/resource.tf
  • add tfplugindocs as "tools model" dependency, i.e. in tools/tools.go:
    // +build tools
    
    package tools
    
    //go:generate go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
    
    import (
      // docs generator
      _ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs"
    )
  • add //go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs to <repo_dir>/main.go

@ocobles
Copy link
Contributor

ocobles commented Jun 21, 2022

The drafts pull request equinix/terraform-provider-metal#15 and equinix/terraform-provider-metal#132 created at equinix/terraform-provider-metal have been closed without resolution due to the complexity of migrating that work to this repository. Any related work must be recreated. Relevant information from the conversation is linked below:

equinix/terraform-provider-metal#15 (comment)

Have a look at this thread, tinkerbell/terraform-provider-tinkerbell#20 (comment) and this commit tinkerbell/terraform-provider-tinkerbell@1d2377d.

I think this provides a cleaner approach to introducing this bit of tooling without adding dozens of new requirements.

@ctreatma
Copy link
Contributor

The provider will likely need to adopt documentation generation in a major version release, because we cannot generate docs in the current structure where files are prefix with equinix_: (hashicorp/terraform-plugin-docs#347). Our current file naming convention does not align with the standards proposed by Hashicorp and implemented in the generator.

Rather than fork the generator or do extra workarounds to rename files after generation, we should align with the standards that are implemented by the generator and that are used by other providers; that means breaking existing docs pages because there's no way to redirect those old URLs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request source/terraform-provider-metal This issue/pr was originally created in deprecated terraform-provider-metal repository
Projects
None yet
4 participants