Skip to content

Commit

Permalink
check: Prefer terraform code block language over hcl in examples (#…
Browse files Browse the repository at this point in the history
…47)

Reference: #21
  • Loading branch information
bflad authored Feb 25, 2021
1 parent f257adb commit 519f443
Show file tree
Hide file tree
Showing 38 changed files with 42 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# v0.9.0

BREAKING CHANGES

* check: Prefer `terraform` code block language over `hcl` in examples with experimental `-enable-contents-check` flag

ENHANCEMENTS

* check: Add `-provider-source` option (support Terraform CLI 0.13 and later `-providers-schema-json` file)
Expand Down
4 changes: 2 additions & 2 deletions check/contents/check_example_section.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func (d *Document) checkExampleSection() error {
for _, fencedCodeBlock := range section.FencedCodeBlocks {
language := markdown.FencedCodeBlockLanguage(fencedCodeBlock, d.source)

if language != markdown.FencedCodeBlockLanguageHcl && language != markdown.FencedCodeBlockLanguageTerraform {
return fmt.Errorf("example section code block language (%s) should be: ```%s or ```%s", language, markdown.FencedCodeBlockLanguageHcl, markdown.FencedCodeBlockLanguageTerraform)
if language != markdown.FencedCodeBlockLanguageTerraform {
return fmt.Errorf("example section code block language (%s) should be: ```%s", language, markdown.FencedCodeBlockLanguageTerraform)
}

text := markdown.FencedCodeBlockText(fencedCodeBlock, d.source)
Expand Down
2 changes: 1 addition & 1 deletion check/contents/testdata/example/missing_heading.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manages an Example Thing.

```hcl
```terraform
resource "test_missing_heading" "example" {
name = "example"
}
Expand Down
2 changes: 1 addition & 1 deletion check/contents/testdata/example/passing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Example Usage

```hcl
```terraform
resource "test_passing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Example Usage

```tf
```hcl
resource "test_wrong_code_block_language" "example" {
name = "example"
}
Expand Down
2 changes: 1 addition & 1 deletion check/contents/testdata/example/wrong_heading_level.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Example Usage

```hcl
```terraform
resource "test_wrong_heading_level" "example" {
name = "example"
}
Expand Down
2 changes: 1 addition & 1 deletion check/contents/testdata/example/wrong_heading_text.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Examples

```hcl
```terraform
resource "test_wrong_heading_text" "example" {
name = "example"
}
Expand Down
2 changes: 1 addition & 1 deletion check/contents/testdata/full.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Manages a Test Full.

## Example Usage

```hcl
```terraform
resource "test_full" "example" {
name = "example"
}
Expand Down
2 changes: 1 addition & 1 deletion check/contents/testdata/title/missing_heading.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manages an Example Thing.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
2 changes: 1 addition & 1 deletion check/contents/testdata/title/passing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Manages an Example Thing.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
data "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
data "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Byline.

## Example Usage

```hcl
```terraform
data "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Byline.

## Example Usage

```hcl
```terraform
data "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Byline.

## Example Usage

```hcl
```terraform
data "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Byline.

## Example Usage

```hcl
```terraform
data "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
data "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
data "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
data "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
data "example_thing" "example" {
name = "example"
}
Expand Down
2 changes: 1 addition & 1 deletion check/testdata/valid-legacy-files/resource.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Byline.

## Example Usage

```hcl
```terraform
data "example_thing" "example" {
name = "example"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down
2 changes: 1 addition & 1 deletion check/testdata/valid-registry-files/data_source.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Byline.

## Example Usage

```hcl
```terraform
data "example_thing" "example" {
name = "example"
}
Expand Down
2 changes: 1 addition & 1 deletion check/testdata/valid-registry-files/resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Byline.

## Example Usage

```hcl
```terraform
resource "example_thing" "example" {
name = "example"
}
Expand Down

0 comments on commit 519f443

Please sign in to comment.