Skip to content

Commit

Permalink
docs: add thanks page (golangci#2893)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored and SeigeC committed Apr 4, 2023
1 parent b81109c commit 2238a59
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 21 deletions.
2 changes: 2 additions & 0 deletions docs/src/config/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
items:
- label: "Roadmap"
link: "/product/roadmap/"
- label: "Thanks"
link: "/product/thanks/"
- label: "Trusted By"
link: "/product/trusted-by/"
- label: "GitHub"
Expand Down
9 changes: 0 additions & 9 deletions docs/src/docs/product/roadmap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ Please file an issue for bugs, missing documentation, or unexpected behavior.

[See Bugs](https://github.com/golangci/golangci-lint/issues?utf8=✓&q=is%3Aissue+is%3Aopen+label%3A%22bug%22+sort%3Acreated-desc)

## Thanks

Thanks to all [contributors](https://github.com/golangci/golangci-lint/graphs/contributors)!
Thanks to [alecthomas/gometalinter](https://github.com/alecthomas/gometalinter) for inspiration and amazing work.
Thanks to [bradleyfalzon/revgrep](https://github.com/bradleyfalzon/revgrep) for cool diff tool.

Thanks to developers and authors of used linters:
{.ThanksList}

## Changelog

{.ChangeLog}
Expand Down
14 changes: 14 additions & 0 deletions docs/src/docs/product/thanks.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Thanks
---

## ❤️

Thanks to all [contributors](https://github.com/golangci/golangci-lint/graphs/contributors)!

Thanks to [alecthomas/gometalinter](https://github.com/alecthomas/gometalinter) for inspiration and amazing work.
Thanks to [bradleyfalzon/revgrep](https://github.com/bradleyfalzon/revgrep) for cool diff tool.

Thanks to developers and authors of used linters:

{.ThanksList}
69 changes: 57 additions & 12 deletions scripts/expand_website_templates/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,34 +313,79 @@ func spanWithID(id, title, icon string) string {
return fmt.Sprintf(`<span id=%q title=%q>%s</span>`, id, title, icon)
}

type authorDetails struct {
Linters []string
Profile string
Avatar string
}

func getThanksList() string {
var lines []string
addedAuthors := map[string]bool{}
addedAuthors := map[string]*authorDetails{}

for _, lc := range lintersdb.NewManager(nil, nil).GetAllSupportedLinterConfigs() {
if lc.OriginalURL == "" {
continue
}

const githubPrefix = "https://github.com/"
if !strings.HasPrefix(lc.OriginalURL, githubPrefix) {
continue
linterURL := lc.OriginalURL
if lc.Name() == "staticcheck" {
linterURL = "https://github.com/dominikh/go-tools"
}

githubSuffix := strings.TrimPrefix(lc.OriginalURL, githubPrefix)
githubAuthor := strings.Split(githubSuffix, "/")[0]
if addedAuthors[githubAuthor] {
if author := extractAuthor(linterURL, "https://github.com/"); author != "" && author != "golangci" {
if _, ok := addedAuthors[author]; ok {
addedAuthors[author].Linters = append(addedAuthors[author].Linters, lc.Name())
} else {
addedAuthors[author] = &authorDetails{
Linters: []string{lc.Name()},
Profile: fmt.Sprintf("[%[1]s](https://github.com/sponsors/%[1]s)", author),
Avatar: fmt.Sprintf(`<img src="https://github.com/%[1]s.png" alt="%[1]s" style="max-width: 100%%;" width="20px;" />`, author),
}
}
} else if author := extractAuthor(linterURL, "https://gitlab.com/"); author != "" {
if _, ok := addedAuthors[author]; ok {
addedAuthors[author].Linters = append(addedAuthors[author].Linters, lc.Name())
} else {
addedAuthors[author] = &authorDetails{
Linters: []string{lc.Name()},
Profile: fmt.Sprintf("[%[1]s](https://gitlab.com/%[1]s)", author),
}
}
} else {
continue
}
addedAuthors[githubAuthor] = true
}

line := fmt.Sprintf("- [%s](https://github.com/%s)",
githubAuthor, githubAuthor)
lines = append(lines, line)
var authors []string
for author := range addedAuthors {
authors = append(authors, author)
}

sort.Slice(authors, func(i, j int) bool {
return strings.ToLower(authors[i]) < strings.ToLower(authors[j])
})

lines := []string{
"|Author|Linter(s)|",
"|---|---|",
}

for _, author := range authors {
lines = append(lines, fmt.Sprintf("|%s %s|%s|",
addedAuthors[author].Avatar, addedAuthors[author].Profile, strings.Join(addedAuthors[author].Linters, ", ")))
}

return strings.Join(lines, "\n")
}

func extractAuthor(originalURL, prefix string) string {
if !strings.HasPrefix(originalURL, prefix) {
return ""
}

return strings.SplitN(strings.TrimPrefix(originalURL, prefix), "/", 2)[0]
}

type SettingSnippets struct {
ConfigurationFile string
LintersSettings string
Expand Down

0 comments on commit 2238a59

Please sign in to comment.