File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,12 @@ import (
1818 "io/ioutil"
1919 "path/filepath"
2020 "regexp"
21+ "sort"
2122 "strings"
2223
2324 "emperror.dev/errors"
2425 "github.com/go-logr/logr"
26+ "github.com/iancoleman/orderedmap"
2527)
2628
2729type SourceLister struct {
@@ -53,7 +55,9 @@ func NewSourceLister(sources map[string]SourceDir, logger logr.Logger) *SourceLi
5355
5456func (sl * SourceLister ) ListSources () ([]DocItem , error ) {
5557 sourceList := []DocItem {}
56- for category , p := range sl .Sources {
58+
59+ for _ , key := range orderedMap (sl .Sources ).Keys () {
60+ p := sl .Sources [key ]
5761 files , err := ioutil .ReadDir (p .Path )
5862 if err != nil {
5963 return nil , errors .WrapIff (err , "failed to read files from %s" , p .Path )
@@ -67,7 +71,7 @@ func (sl *SourceLister) ListSources() ([]DocItem, error) {
6771 SourcePath : fullPath ,
6872 DestPath : p .DestPath ,
6973 DefaultValueFromTagExtractor : sl .DefaultValueFromTagExtractor ,
70- Category : category ,
74+ Category : key ,
7175 },
7276 )
7377 }
@@ -118,3 +122,12 @@ func (lister *SourceLister) Generate() error {
118122
119123 return nil
120124}
125+
126+ func orderedMap (original map [string ]SourceDir ) * orderedmap.OrderedMap {
127+ o := orderedmap .New ()
128+ for k , v := range original {
129+ o .Set (k , v )
130+ }
131+ o .SortKeys (sort .Strings )
132+ return o
133+ }
You can’t perform that action at this time.
0 commit comments