forked from openshift/osde2e
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs.go
More file actions
64 lines (52 loc) · 1.14 KB
/
docs.go
File metadata and controls
64 lines (52 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import "sort"
type DocsData struct {
Title string
Sections []Section
}
func (d *DocsData) Populate(opts map[string]Options) {
for sectName, sectOpts := range opts {
sort.Sort(sectOpts)
// put options into a section defaulting to other
sectID := d.SectionID(sectName)
if sectID < 0 {
if sectID = d.SectionID("other"); sectID < 0 {
sectID = len(d.Sections)
d.Sections = append(d.Sections, Section{
Name: "other",
Description: "Various additional options for configuring osde2e.",
})
}
}
d.Sections[sectID].Options = append(d.Sections[sectID].Options, sectOpts...)
}
}
func (d *DocsData) SectionID(name string) int {
for i, sect := range d.Sections {
if sect.Name == name {
return i
}
}
return -1
}
type Section struct {
Name string
Description string
Options
}
type Options []Option
func (o Options) Len() int {
return len(o)
}
func (o Options) Swap(i, j int) {
o[i], o[j] = o[j], o[i]
}
func (o Options) Less(i, j int) bool {
return o[i].Variable < o[j].Variable
}
type Option struct {
Variable string
Description string
Type string
DefaultValue string
}