1+ // Copyright 2019 HAProxy Technologies LLC
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
115package main
216
317import (
@@ -7,6 +21,8 @@ import (
721 "strings"
822
923 "github.com/google/renameio"
24+ "golang.org/x/text/cases"
25+ "golang.org/x/text/language"
1026)
1127
1228var header = `
@@ -133,11 +149,13 @@ func (c *Conf) generateReadmeAnnotations() {
133149 sortedGroups = append (sortedGroups , group )
134150 }
135151 sort .Strings (sortedGroups )
152+ caser := cases .Title (language .Und )
136153 for _ , group := range sortedGroups {
137- buff .WriteString (fmt .Sprintf ("#### %s\n \n " , strings .ReplaceAll (strings . Title (group ), "-" , " " )))
154+ buff .WriteString (fmt .Sprintf ("#### %s\n \n " , strings .ReplaceAll (caser . String (group ), "-" , " " )))
138155 groupData , haveGroupData := c .Groups [group ]
139156 if haveGroupData && groupData .Header != "" {
140- buff .WriteString (fmt .Sprintf ("%s\n \n " , groupData .Header ))
157+ buff .WriteString (groupData .Header )
158+ buff .WriteString ("\n \n " )
141159 }
142160 for _ , ann := range c .Items {
143161 if ann .Group != group {
@@ -166,14 +184,15 @@ func (c *Conf) generateReadmeAnnotations() {
166184 selectExamples (ann , & buff )
167185 }
168186 if haveGroupData && groupData .Footer != "" {
169- buff .WriteString (fmt .Sprintf ("%s\n \n " , groupData .Footer ))
187+ buff .WriteString (groupData .Footer )
188+ buff .WriteString ("\n \n " )
170189 }
171190 buff .WriteString ("<p align='right'><a href='#available-annotations'>:arrow_up_small: back to top</a></p>\n \n ***\n \n " )
172191 }
173192
174193 buff .WriteString (docFooter )
175194
176- err := renameio .WriteFile ("../annotations.md" , []byte (buff .String ()), 0o644 )
195+ err := renameio .WriteFile ("../../documentation/ annotations.md" , []byte (buff .String ()), 0o644 )
177196 if err != nil {
178197 log .Println (err )
179198 }
0 commit comments