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
fix(template functions): Use function Title instead of ToTitle #165
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,3 +1,9 @@ | ||||||||||
# 0.12.1 (July 04, 2022) | ||||||||||
|
||||||||||
BUG FIXES: | ||||||||||
|
||||||||||
* template functions: funtion `title` creates capitalize strings instead of upper strings ([#165](https://github.com/hashicorp/terraform-plugin-docs/pull/165)). | ||||||||||
|
||||||||||
# 0.12.0 (June 29, 2022) | ||||||||||
|
||||||||||
BUG FIXES: | ||||||||||
|
@@ -71,13 +77,13 @@ BUG FIXES: | |||||||||
|
||||||||||
ENHANCEMENTS: | ||||||||||
|
||||||||||
* cmd/tfplugindocs: Use existing Terraform CLI binary if available on PATH, otherwise download latest Terraform CLI binary (https://github.com/hashicorp/terraform-plugin-docs/pull/124). | ||||||||||
* cmd/tfplugindocs: Added `tf-version` flag for specifying Terraform CLI binary version to download, superseding the PATH lookup (https://github.com/hashicorp/terraform-plugin-docs/pull/124). | ||||||||||
* cmd/tfplugindocs: Use existing Terraform CLI binary if available on PATH, otherwise download latest Terraform CLI binary (<https://github.com/hashicorp/terraform-plugin-docs/pull/124>). | ||||||||||
* cmd/tfplugindocs: Added `tf-version` flag for specifying Terraform CLI binary version to download, superseding the PATH lookup (<https://github.com/hashicorp/terraform-plugin-docs/pull/124>). | ||||||||||
Comment on lines
+80
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
BUG FIXES: | ||||||||||
|
||||||||||
* cmd/tfplugindocs: Swapped `.Type` and `.Name` resource and data source template fields so they correctly align (https://github.com/hashicorp/terraform-plugin-docs/pull/44). | ||||||||||
* schemamd: Switched attribute name rendering from bold text to code blocks so the Terraform Registry treats them as anchor links (https://github.com/hashicorp/terraform-plugin-docs/pull/59). | ||||||||||
* cmd/tfplugindocs: Swapped `.Type` and `.Name` resource and data source template fields so they correctly align (<https://github.com/hashicorp/terraform-plugin-docs/pull/44>). | ||||||||||
* schemamd: Switched attribute name rendering from bold text to code blocks so the Terraform Registry treats them as anchor links (<https://github.com/hashicorp/terraform-plugin-docs/pull/59>). | ||||||||||
Comment on lines
+85
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for spotting those, but the format should be |
||||||||||
|
||||||||||
# 0.6.0 (March 14, 2022) | ||||||||||
|
||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,10 +168,10 @@ using the following data fields and functions: | |
| `plainmarkdown` | Render Markdown content as plaintext. | | ||
| `prefixlines` | Add a prefix to all (newline-separated) lines in a string. | | ||
| `split` | Split string into sub-strings, by a given separator (ex. `split .Name "_"`). | | ||
| `title` | Equivalent to [`strings.ToLower`](https://pkg.go.dev/strings#ToTitle). | | ||
| `title` | Equivalent to [`cases.Title`](https://pkg.go.dev/golang.org/x/text/cases#Title). | | ||
| `tffile` | A special case of the `codefile` function, designed for Terraform files (i.e. `.tf`). | | ||
| `trimspace` | Equivalent to [`strings.TrimSpace`](https://pkg.go.dev/strings#TrimSpace). | | ||
| `upper` | Equivalent to [`strings.ToLower`](https://pkg.go.dev/strings#ToUpper). | | ||
| `upper` | Equivalent to [`strings.ToUpper`](https://pkg.go.dev/strings#ToUpper). | | ||
Comment on lines
+171
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well spotted! |
||
|
||
## Disclaimer | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package provider | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
) | ||
|
||
func TestRenderStringTemplate(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks so much for those tests. Really appreciated. |
||
template := ` | ||
Plainmarkdown: {{ plainmarkdown .Text }} | ||
Split: {{ $arr := split .Text " "}}{{ index $arr 3 }} | ||
Trimspace: {{ trimspace .Text }} | ||
Lower: {{ upper .Text }} | ||
Upper: {{ lower .Text }} | ||
Title: {{ title .Text }} | ||
Prefixlines: | ||
{{ prefixlines " " .MultiLineTest }} | ||
` | ||
|
||
expectedString := ` | ||
Plainmarkdown: my Odly cAsed striNg | ||
Split: striNg | ||
Trimspace: my Odly cAsed striNg | ||
Lower: MY ODLY CASED STRING | ||
Upper: my odly cased string | ||
Title: My Odly Cased String | ||
Prefixlines: | ||
This text used | ||
multiple lines | ||
` | ||
result, err := renderStringTemplate("testTemplate", template, struct { | ||
Text string | ||
MultiLineTest string | ||
}{ | ||
Text: "my Odly cAsed striNg", | ||
MultiLineTest: `This text used | ||
multiple lines`, | ||
}) | ||
|
||
if err != nil { | ||
t.Error(err) | ||
} | ||
if !cmp.Equal(expectedString, result) { | ||
t.Errorf("expected: %+v, got: %+v", expectedString, result) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another PR landed so I think you need to rebase and put this in the
0.13.0
section, but still underBUG FIXES
.