Skip to content

Commit 97db939

Browse files
committed
feat: item settings shortcode
1 parent 0cdb64f commit 97db939

File tree

3 files changed

+94
-2
lines changed

3 files changed

+94
-2
lines changed

docs/content/docs/formatters/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ title: Settings
33
weight: 2
44
---
55

6-
{ .FormattersExample }
6+
{{% item-settings info="formatters_info" settings="formatter_settings" %}}

docs/content/docs/linters/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ title: Settings
33
weight: 2
44
---
55

6-
{ .LintersExample }
6+
{{% item-settings info="linters_info" settings="linter_settings" %}}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{{- /*
2+
Creates a section for each setting of a linter/formatter.
3+
4+
@param {string} info The name of the data file containing the linter/formatter information.
5+
@param {string} settings The name of the data file containing the linter/formatter settings.
6+
7+
@example {{% item-settings info="formatters_info" settings="formatter_settings" %}}
8+
*/ -}}
9+
10+
{{- $fileInfo := .Get "info" -}}
11+
{{- $fileSettings := .Get "settings" -}}
12+
13+
{{- $gcilVersion := index $.Site.Data.version.version -}}
14+
{{- $info := index $.Site.Data $fileInfo -}}
15+
{{- $settings := index $.Site.Data $fileSettings -}}
16+
17+
{{- range sort $info "name" -}}
18+
{{- if .internal -}}
19+
{{- continue -}}
20+
{{- end -}}
21+
22+
## {{ .name }}
23+
24+
{{/* Description */}}
25+
{{ if .deprecation -}}
26+
{{- $replacement := "" -}}
27+
{{- if .deprecation.replacement -}}
28+
{{- $replacement = print " Use `" .deprecation.replacement "` instead." -}}
29+
{{- end -}}
30+
{{ print (partial "format-description" .deprecation.message) $replacement }}
31+
{{ else }}
32+
{{ partial "format-description" .desc }}
33+
{{ end }}
34+
35+
{{/* Badges */}}
36+
<p>
37+
{{ partial "shortcodes/badge.html" (dict
38+
"border" true
39+
"icon" "calendar"
40+
"content" (print "Since golangci-lint " .since)
41+
)
42+
}}
43+
{{ if .deprecation -}}
44+
{{ partial "shortcodes/badge.html" (dict
45+
"border" true
46+
"icon" "sparkles"
47+
"content" (print "Deprecated since " .deprecation.since)
48+
"type" "error"
49+
)
50+
}}
51+
{{ else }}
52+
{{ if (partial "compare-versions.html" (dict "a" $gcilVersion "b" .since)) }}
53+
{{ partial "shortcodes/badge.html" (dict
54+
"border" true
55+
"icon" "sparkles"
56+
"content" "New"
57+
"type" "warning"
58+
)
59+
}}
60+
{{ end }}
61+
{{ if .canAutoFix }}
62+
{{ partial "shortcodes/badge.html" (dict
63+
"border" true
64+
"icon" "sparkles"
65+
"content" "Autofix"
66+
"type" "info"
67+
)
68+
}}
69+
{{ end }}
70+
{{ end }}
71+
<a href="{{ .originalURL }}" title="Repository" target="_blank">
72+
{{ partial "shortcodes/badge.html" (dict
73+
"border" true
74+
"icon" "github"
75+
"content" "Repository"
76+
"link" .originalURL
77+
)
78+
}}
79+
</a>
80+
</p>
81+
82+
{{/* Settings */}}
83+
{{- $setting := index $settings .name -}}
84+
{{- if $setting -}}
85+
```yaml
86+
{{ $setting | safeHTML}}
87+
```
88+
{{- else -}}
89+
_No settings available._
90+
{{- end }}
91+
92+
{{ end -}}

0 commit comments

Comments
 (0)