Skip to content

Commit eaf3ff0

Browse files
authored
docs: improve plugins page (#4494)
1 parent 2a1afc1 commit eaf3ff0

File tree

5 files changed

+45
-7
lines changed

5 files changed

+45
-7
lines changed

docs/src/config/sidebar.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
- label: Plugins
5050
items:
5151
- label: Module Plugin System
52-
link: /contributing/new-linters/
52+
link: /plugins/module-plugins/
5353
- label: Go Plugin System
54-
link: /contributing/private-linters/
54+
link: /plugins/go-plugins/
5555

docs/src/docs/plugins/module-plugins.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,11 @@ linters:
6969
enable:
7070
- foo
7171
```
72+
73+
## Reference
74+
75+
The configuration file can be validated with the JSON Schema: https://golangci-lint.run/jsonschema/custom-gcl.jsonschema.json
76+
77+
```yml
78+
{ .CustomGCLReference }
79+
```

scripts/website/expand_templates/linters.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"fmt"
5+
"os"
56
"path/filepath"
67
"reflect"
78
"sort"
@@ -17,6 +18,20 @@ import (
1718

1819
const listItemPrefix = "list-item-"
1920

21+
func getExampleSnippets() (*SettingSnippets, error) {
22+
reference, err := os.ReadFile(".golangci.reference.yml")
23+
if err != nil {
24+
return nil, fmt.Errorf("can't read .golangci.reference.yml: %w", err)
25+
}
26+
27+
snippets, err := extractExampleSnippets(reference)
28+
if err != nil {
29+
return nil, fmt.Errorf("can't extract example snippets from .golangci.reference.yml: %w", err)
30+
}
31+
32+
return snippets, nil
33+
}
34+
2035
func getLintersListMarkdown(enabled bool) string {
2136
linters, err := readJSONFile[[]*types.LinterWrapper](filepath.Join("assets", "linters-info.json"))
2237
if err != nil {

scripts/website/expand_templates/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ func getLatestVersion() (string, error) {
119119
}
120120

121121
func buildTemplateContext() (map[string]string, error) {
122-
golangciYamlExample, err := os.ReadFile(".golangci.reference.yml")
122+
snippets, err := getExampleSnippets()
123123
if err != nil {
124-
return nil, fmt.Errorf("can't read .golangci.reference.yml: %w", err)
124+
return nil, err
125125
}
126126

127-
snippets, err := extractExampleSnippets(golangciYamlExample)
127+
pluginReference, err := getPluginReference()
128128
if err != nil {
129-
return nil, fmt.Errorf("can't read .golangci.reference.yml: %w", err)
129+
return nil, fmt.Errorf("failed to read plugin reference file: %w", err)
130130
}
131131

132132
helps, err := readJSONFile[types.CLIHelp](filepath.Join("assets", "cli-help.json"))
@@ -150,7 +150,7 @@ func buildTemplateContext() (map[string]string, error) {
150150
}
151151

152152
return map[string]string{
153-
"LintersExample": snippets.LintersSettings,
153+
"CustomGCLReference": pluginReference,
154154
"ConfigurationExample": snippets.ConfigurationFile,
155155
"LintersCommandOutputEnabledOnly": helps.Enable,
156156
"LintersCommandOutputDisabledOnly": helps.Disable,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
)
7+
8+
func getPluginReference() (string, error) {
9+
reference, err := os.ReadFile(".custom-gcl.reference.yml")
10+
if err != nil {
11+
return "", fmt.Errorf("can't read .custom-gcl.reference.yml: %w", err)
12+
}
13+
14+
return string(reference), nil
15+
}

0 commit comments

Comments
 (0)