hashicorp / hashicorp/terraform-plugin-docs

Enhance templating functions

Open
#610 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
263
Forks
84
Avg merge
3d 6h
Merged PRs (30d)
2

Description

### Terraform CLI and terraform-plugin-docs Versions

Terraform v1.13.4
tfplugindocs v0.25.0

### Use Cases or Problem Statement

Based on [this](https://github.com/hashicorp/terraform-plugin-docs/issues/591) and some use-cases I've stumbled upon (like that `$lastItem` range 😂 )

One major use-case: creating headings for Example files based on filename suffix

We're currently solving it with:
```
{{- range .ExampleFiles }}

{{- $parts := split . "resource_" -}}
{{- $lastItem := index $parts 1 }}
{{- $fileNameParts := split $lastItem "." }}
{{- $fileName := index $fileNameParts 0 }}

### {{ $fileName | title }}
```

but this is unwieldy and doesn't allow for replacing underscores in longer filenames

### Proposal

I would suggest adding https://github.com/masterminds/sprig functions to the template.

I'm willing to add a PR for this, if that would be fine with you :)

### How much impact is this issue causing?

Low

### Additional Information

_No response_

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating where terraform-plugin-docs configures its Go templates and registers the existing functions; the issue does not name a file or test. Compare that setup with the proposed Sprig integration and verify the result against the documented ExampleFiles heading use case, including replacing underscores in filenames.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
documentation, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.