From f6b9ea77b714718f2aadeb682c7b8b2a8ceefe72 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Fri, 18 Feb 2022 17:23:31 +0100 Subject: [PATCH 1/2] feat: use non-breaking space --- scripts/expand_website_templates/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/expand_website_templates/main.go b/scripts/expand_website_templates/main.go index 3eab1b11c238..91a366c0735e 100644 --- a/scripts/expand_website_templates/main.go +++ b/scripts/expand_website_templates/main.go @@ -257,7 +257,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, span("Configuration", "⚙️"), lc.Name()) } if !lc.IsDeprecated() { @@ -269,7 +269,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 { From ab27ca517d9ff46d81369b409bb9f72513dd051a Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Fri, 18 Feb 2022 17:23:58 +0100 Subject: [PATCH 2/2] feat: add back on top button --- scripts/expand_website_templates/main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/expand_website_templates/main.go b/scripts/expand_website_templates/main.go index 91a366c0735e..c1afb699e633 100644 --- a/scripts/expand_website_templates/main.go +++ b/scripts/expand_website_templates/main.go @@ -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() { @@ -307,6 +309,10 @@ func span(title, icon string) string { return fmt.Sprintf(`%s`, title, icon) } +func spanWithID(id, title, icon string) string { + return fmt.Sprintf(`%s`, 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