docs: improve plugins page (#4494)
This commit is contained in:
parent
2a1afc14cb
commit
eaf3ff0741
@ -49,7 +49,7 @@
|
|||||||
- label: Plugins
|
- label: Plugins
|
||||||
items:
|
items:
|
||||||
- label: Module Plugin System
|
- label: Module Plugin System
|
||||||
link: /contributing/new-linters/
|
link: /plugins/module-plugins/
|
||||||
- label: Go Plugin System
|
- label: Go Plugin System
|
||||||
link: /contributing/private-linters/
|
link: /plugins/go-plugins/
|
||||||
|
|
||||||
|
@ -69,3 +69,11 @@ linters:
|
|||||||
enable:
|
enable:
|
||||||
- foo
|
- foo
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Reference
|
||||||
|
|
||||||
|
The configuration file can be validated with the JSON Schema: https://golangci-lint.run/jsonschema/custom-gcl.jsonschema.json
|
||||||
|
|
||||||
|
```yml
|
||||||
|
{ .CustomGCLReference }
|
||||||
|
```
|
||||||
|
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
@ -17,6 +18,20 @@ import (
|
|||||||
|
|
||||||
const listItemPrefix = "list-item-"
|
const listItemPrefix = "list-item-"
|
||||||
|
|
||||||
|
func getExampleSnippets() (*SettingSnippets, error) {
|
||||||
|
reference, err := os.ReadFile(".golangci.reference.yml")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("can't read .golangci.reference.yml: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
snippets, err := extractExampleSnippets(reference)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("can't extract example snippets from .golangci.reference.yml: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return snippets, nil
|
||||||
|
}
|
||||||
|
|
||||||
func getLintersListMarkdown(enabled bool) string {
|
func getLintersListMarkdown(enabled bool) string {
|
||||||
linters, err := readJSONFile[[]*types.LinterWrapper](filepath.Join("assets", "linters-info.json"))
|
linters, err := readJSONFile[[]*types.LinterWrapper](filepath.Join("assets", "linters-info.json"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -119,14 +119,14 @@ func getLatestVersion() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func buildTemplateContext() (map[string]string, error) {
|
func buildTemplateContext() (map[string]string, error) {
|
||||||
golangciYamlExample, err := os.ReadFile(".golangci.reference.yml")
|
snippets, err := getExampleSnippets()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't read .golangci.reference.yml: %w", err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
snippets, err := extractExampleSnippets(golangciYamlExample)
|
pluginReference, err := getPluginReference()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't read .golangci.reference.yml: %w", err)
|
return nil, fmt.Errorf("failed to read plugin reference file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
helps, err := readJSONFile[types.CLIHelp](filepath.Join("assets", "cli-help.json"))
|
helps, err := readJSONFile[types.CLIHelp](filepath.Join("assets", "cli-help.json"))
|
||||||
@ -150,7 +150,7 @@ func buildTemplateContext() (map[string]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return map[string]string{
|
return map[string]string{
|
||||||
"LintersExample": snippets.LintersSettings,
|
"CustomGCLReference": pluginReference,
|
||||||
"ConfigurationExample": snippets.ConfigurationFile,
|
"ConfigurationExample": snippets.ConfigurationFile,
|
||||||
"LintersCommandOutputEnabledOnly": helps.Enable,
|
"LintersCommandOutputEnabledOnly": helps.Enable,
|
||||||
"LintersCommandOutputDisabledOnly": helps.Disable,
|
"LintersCommandOutputDisabledOnly": helps.Disable,
|
||||||
|
15
scripts/website/expand_templates/plugins.go
Normal file
15
scripts/website/expand_templates/plugins.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getPluginReference() (string, error) {
|
||||||
|
reference, err := os.ReadFile(".custom-gcl.reference.yml")
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("can't read .custom-gcl.reference.yml: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(reference), nil
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user