Skip to content

Support cross-file go templates #513

Description

@Kirdock

Terraform CLI and terraform-plugin-docs Versions

Terraform: v1.11.3 on windows_amd64
tfplugindocs: latest (dev)

Use Cases or Problem Statement

At the moment, it's only possible to reference and re-use different files via codefile and tffile. Both of them are markdown and it's not possible to include other template files or simply files without adding backticks for the markdown. The go templating function template can't be used because it doesn't get the references/defines of other files.
Adding this functionality would be very useful if several resources have common documentation parts like limitations or warnings.

Proposal

Supporting the go templating function template so that it gets references and considers other template files.
e.g.,

templates/
├── partials/
│   ├── my-custom-template.tmpl
├── resources/
│   ├── my-resource.md.tmpl

my-resource.md.tmpl

# My Resource Documentation

This is the documentation for `my-resource`.

{{ template "my-custom-template" . }}

my-custom-template.tmpl

{{ define "my-custom-template" }}
## My Custom Template

This is reusable content for my custom template.
{{ end }}

How much impact is this issue causing?

Low

Additional Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions