Skip to content

Commit

Permalink
docs: add link to configuration in the linters list
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Feb 17, 2022
1 parent ed93066 commit 3a16eb3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion scripts/expand_website_templates/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import (
"os"
"os/exec"
"path/filepath"
"reflect"
"sort"
"strings"

"gopkg.in/yaml.v3"

"github.com/golangci/golangci-lint/internal/renameio"
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
)
Expand Down Expand Up @@ -251,7 +253,11 @@ func getName(lc *linter.Config) string {
name := lc.Name()

if lc.OriginalURL != "" {
name = fmt.Sprintf("[%s](%s)", lc.Name(), lc.OriginalURL)
name = fmt.Sprintf("[%s](%s)", name, lc.OriginalURL)
}

if hasSettings(lc.Name()) {
name = fmt.Sprintf("%s [%s](#%s)", name, span("Configuration", "⚙️"), lc.Name())
}

if !lc.IsDeprecated() {
Expand Down Expand Up @@ -285,6 +291,18 @@ func check(b bool, title string) string {
return ""
}

func hasSettings(name string) bool {
tp := reflect.TypeOf(config.LintersSettings{})

for i := 0; i < tp.NumField(); i++ {
if strings.EqualFold(name, tp.Field(i).Name) {
return true
}
}

return false
}

func span(title, icon string) string {
return fmt.Sprintf(`<span title=%q>%s</span>`, title, icon)
}
Expand Down

0 comments on commit 3a16eb3

Please sign in to comment.