docs: add "back to the top" button (#2602)

* feat: use non-breaking space
* feat: add back on top button
This commit is contained in:
Ludovic Fernandez 2022-02-19 04:55:30 +01:00 committed by GitHub
parent 5ddb5e7a90
commit 0831dacc29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,8 @@ import (
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
)
const listItemPrefix = "list-item-"
var stateFilePath = filepath.Join("docs", "template_data.state")
func main() {
@ -257,7 +259,7 @@ func getName(lc *linter.Config) string {
}
if hasSettings(lc.Name()) {
name = fmt.Sprintf("%s [%s](#%s)", name, span("Configuration", "⚙️"), lc.Name())
name = fmt.Sprintf("%s [%s](#%s)", name, spanWithID(listItemPrefix+lc.Name(), "Configuration", "⚙️"), lc.Name())
}
if !lc.IsDeprecated() {
@ -269,7 +271,7 @@ func getName(lc *linter.Config) string {
title += fmt.Sprintf(" since %s", lc.Deprecation.Since)
}
return name + " " + span(title, "⚠")
return name + " " + span(title, "⚠")
}
func getDesc(lc *linter.Config) string {
@ -307,6 +309,10 @@ func span(title, icon string) string {
return fmt.Sprintf(`<span title=%q>%s</span>`, title, icon)
}
func spanWithID(id, title, icon string) string {
return fmt.Sprintf(`<span id=%q title=%q>%s</span>`, id, title, icon)
}
func getThanksList() string {
var lines []string
addedAuthors := map[string]bool{}
@ -472,6 +478,8 @@ func getLintersSettingSnippets(node, nextNode *yaml.Node) (string, error) {
_, _ = fmt.Fprintln(builder, "```")
_, _ = fmt.Fprintln(builder)
_, _ = fmt.Fprintf(builder, "[%s](#%s)\n\n", span("Back to the top", "🔼"), listItemPrefix+nextNode.Content[i].Value)
_, _ = fmt.Fprintln(builder)
}
return builder.String(), nil