{{- /*
Creates a section for each setting of a linter/formatter.

@param {string} info The name of the data file containing the linter/formatter information.
@param {string} settings The name of the data file containing the linter/formatter settings.

@example {{% golangci/items/settings info="formatters_info" settings="formatter_settings" %}}
*/ -}}

{{- $fileInfo := .Get "info" -}}
{{- $fileSettings := .Get "settings" -}}

{{- $gcilVersion := index hugo.Data.version.version -}}
{{- $info := index hugo.Data $fileInfo -}}
{{- $settings := index hugo.Data $fileSettings -}}

{{- range sort $info "name" -}}
{{- if .internal -}}
    {{- continue -}}
{{- end -}}

## {{ .name }}

{{/* Description */}}
{{ if .deprecation -}}
{{- $replacement := "" -}}
{{- if .deprecation.replacement -}}
{{- $replacement = print " Use `" .deprecation.replacement "` instead." -}}
{{- end -}}
{{ print (partial "golangci/items/format-description" .deprecation.message) $replacement }}
{{ else }}
{{ partial "golangci/items/format-description" .desc }}
{{ end }}

{{/* Badges */}}
<p>
{{ partial "shortcodes/badge" (dict
    "border" false
    "icon" "calendar"
    "class" "hx:mx-1"
    "content" (print "Since golangci-lint " .since)
    )
}}
{{ if .deprecation -}}
{{ partial "shortcodes/badge" (dict
    "border" true
    "icon" "sparkles"
    "class" "hx:mx-1"
    "content" (print "Deprecated since " .deprecation.since)
    "color" "red"
    )
    }}
{{ else }}
    {{ if (partial "golangci/items/compare-versions" (dict "a" $gcilVersion "b" .since)) }}
{{ partial "shortcodes/badge" (dict
    "border" false
    "icon" "sparkles"
    "class" "hx:mx-1"
    "content" "New"
    "color" "yellow"
    )
}}
    {{ end }}
    {{ if .canAutoFix }}
{{ partial "shortcodes/badge" (dict
    "border" false
    "icon" "sparkles"
    "class" "hx:mx-1"
    "content" "Autofix"
    "color" "blue"
    )
}}
    {{ end }}
{{ end }}
{{- if .originalURL -}}
<a href="{{ .originalURL }}" title="Repository" target="_blank">
{{ partial "shortcodes/badge" (dict
    "border" true
    "icon" "github"
    "class" "hx:mx-1"
    "content" "Repository"
    "link" .originalURL
    )
}}
</a>
{{- end -}}
</p>

{{/* Settings */}}
{{- $setting := index $settings .name -}}
{{- if $setting -}}
```yaml
{{ $setting | safeHTML}}
```
{{- else -}}
_No settings available._
{{- end }}

{{ end -}}
