From a98f1fe4c546244575e68a53eef77860121033e3 Mon Sep 17 00:00:00 2001 From: rsteube Date: Mon, 25 Sep 2023 12:45:44 +0200 Subject: [PATCH] doc: sort conditions --- cmd/carapace/cmd/root.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/carapace/cmd/root.go b/cmd/carapace/cmd/root.go index d1a53c919a..46ab168217 100644 --- a/cmd/carapace/cmd/root.go +++ b/cmd/carapace/cmd/root.go @@ -322,9 +322,15 @@ func printConditions(format string) string { } case "markdown": + sortedNames := make([]string, 0) + for name := range conditions.MacroMap { + sortedNames = append(sortedNames, name) + } + sort.Strings(sortedNames) + s = append(s, "# Conditions", "") - for name, macro := range conditions.MacroMap { - s = append(s, fmt.Sprintf("- [%v](https://pkg.go.dev/github.com/rsteube/carapace-bin/pkg/conditions#Condition%v) %v", name, name, macro.Description)) + for _, name := range sortedNames { + s = append(s, fmt.Sprintf("- [%v](https://pkg.go.dev/github.com/rsteube/carapace-bin/pkg/conditions#Condition%v) %v", name, name, conditions.MacroMap[name].Description)) } } return strings.Join(s, "\n")