mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-28 22:28:43 -04:00
docs: add "back to the top" button (#2602)
* feat: use non-breaking space * feat: add back on top button
This commit is contained in:
parent
5ddb5e7a90
commit
0831dacc29
1 changed files with 10 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue