Skip to content

Commit 67db4cf

Browse files
committed
docs: improve references and add imports and functions docs
1 parent ef87b8a commit 67db4cf

314 files changed

Lines changed: 3653 additions & 3432 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/hack/functions/main.go

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ type Function struct {
3030
func main() {
3131
functionRefContent := "\n\n"
3232
globalFunctionRefContent := "\n\n"
33+
pipelineFunctionRefContent := "\n\n"
3334
functionRefFile := functionPartialBasePath + "reference.mdx"
3435
globalFunctionRefFile := functionPartialBasePath + "reference_global.mdx"
36+
pipelineFunctionRefFile := functionPartialBasePath + "reference_pipeline.mdx"
3537

3638
groups := map[string]*util.Group{}
3739

@@ -74,9 +76,23 @@ func main() {
7476

7577
partialImport := util.GetPartialImport(functionFile, functionRefFile)
7678
partialUse := fmt.Sprintf(util.TemplatePartialUse, util.GetPartialImportName(function.Name))
79+
partialImportGlobal := partialImport
80+
partialUseGlobal := partialUse
81+
partialImportPipeline := partialImport
82+
partialUsePipeline := partialUse
83+
writeRef := true
84+
writeGlobalRef := false
85+
writePipelineRef := false
7786

7887
if function.Group != "" {
7988
groupID := strings.ToLower(function.Group)
89+
90+
globalGroupID := fmt.Sprintf("%s_global", groupID)
91+
globalGroup, globalGroupExists := groups[globalGroupID]
92+
93+
pipelineGroupID := fmt.Sprintf("%s_pipeline", groupID)
94+
pipelineGroup, pipelineGroupExists := groups[pipelineGroupID]
95+
8096
group, groupExists := groups[groupID]
8197
if !groupExists {
8298
group = &util.Group{
@@ -88,20 +104,60 @@ func main() {
88104
groups[groupID] = group
89105
}
90106

107+
writeRef = !groupExists
108+
partialImportGlobal = ""
109+
partialUseGlobal = ""
110+
partialImportPipeline = ""
111+
partialUsePipeline = ""
112+
113+
if !globalGroupExists {
114+
globalGroup = &util.Group{
115+
Name: function.Group,
116+
File: fmt.Sprintf(functionPartialBasePath+"group_%s.mdx", globalGroupID),
117+
Imports: &[]string{},
118+
Content: "\n\n",
119+
}
120+
groups[globalGroupID] = globalGroup
121+
writeGlobalRef = true
122+
partialImportGlobal = util.GetPartialImport(globalGroup.File, globalFunctionRefFile)
123+
partialUseGlobal = fmt.Sprintf(util.TemplatePartialUse, util.GetPartialImportName(globalGroup.File))
124+
}
125+
126+
if !pipelineGroupExists {
127+
pipelineGroup = &util.Group{
128+
Name: function.Group,
129+
File: fmt.Sprintf(functionPartialBasePath+"group_%s.mdx", pipelineGroupID),
130+
Imports: &[]string{},
131+
Content: "\n\n",
132+
}
133+
groups[pipelineGroupID] = pipelineGroup
134+
writePipelineRef = true
135+
partialImportPipeline = util.GetPartialImport(pipelineGroup.File, pipelineFunctionRefFile)
136+
partialUsePipeline = fmt.Sprintf(util.TemplatePartialUse, util.GetPartialImportName(pipelineGroup.File))
137+
}
138+
91139
group.Content = partialImport + group.Content + partialUse
92140

93-
if groupExists {
94-
continue
141+
if function.IsGlobal {
142+
globalGroup.Content = partialImport + globalGroup.Content + partialUse
143+
} else {
144+
pipelineGroup.Content = partialImport + pipelineGroup.Content + partialUse
95145
}
96146

97147
partialImport = util.GetPartialImport(group.File, functionRefFile)
98148
partialUse = fmt.Sprintf(util.TemplatePartialUse, util.GetPartialImportName(group.File))
99149
}
100150

101-
functionRefContent = partialImport + functionRefContent + partialUse
151+
if writeRef {
152+
functionRefContent = partialImport + functionRefContent + partialUse
153+
}
102154

103-
if function.IsGlobal {
104-
globalFunctionRefContent = partialImport + globalFunctionRefContent + partialUse
155+
if writeGlobalRef {
156+
globalFunctionRefContent = partialImportGlobal + globalFunctionRefContent + partialUseGlobal
157+
}
158+
159+
if writePipelineRef {
160+
pipelineFunctionRefContent = partialImportPipeline + pipelineFunctionRefContent + partialUsePipeline
105161
}
106162
}
107163

@@ -116,6 +172,11 @@ func main() {
116172
if err != nil {
117173
panic(err)
118174
}
175+
176+
err = ioutil.WriteFile(pipelineFunctionRefFile, []byte(pipelineFunctionRefContent), os.ModePerm)
177+
if err != nil {
178+
panic(err)
179+
}
119180
}
120181

121182
func getFlagReference(functionName, functionFile string, flagRef reflect.Type, partialImports *[]string, pageContent string) string {

docs/hack/util/groups.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io/ioutil"
66
"os"
77
"path/filepath"
8+
"strings"
89
)
910

1011
type Group struct {
@@ -17,21 +18,24 @@ type Group struct {
1718
func ProcessGroups(groups map[string]*Group) {
1819
for groupID, group := range groups {
1920
groupContent := group.Content
21+
groupFileContent := ""
2022

21-
if group.Name != "" {
22-
groupContent = "\n" + `<div className="group-name">` + group.Name + `</div>` + "\n\n" + groupContent
23-
}
23+
if strings.TrimSpace(group.Content) != "" {
24+
if group.Name != "" {
25+
groupContent = "\n" + `<div className="group-name">` + group.Name + `</div>` + "\n\n" + groupContent
26+
}
2427

25-
groupImportContent := ""
26-
for _, partialFile := range *group.Imports {
27-
groupImportContent = groupImportContent + GetPartialImport(partialFile, group.File)
28-
}
28+
groupImportContent := ""
29+
for _, partialFile := range *group.Imports {
30+
groupImportContent = groupImportContent + GetPartialImport(partialFile, group.File)
31+
}
2932

30-
if groupImportContent != "" {
31-
groupImportContent = groupImportContent + "\n\n"
32-
}
33+
if groupImportContent != "" {
34+
groupImportContent = groupImportContent + "\n\n"
35+
}
3336

34-
groupFileContent := fmt.Sprintf(`%s<div className="group" data-group="%s">%s`+"\n"+`</div>`, groupImportContent, groupID, groupContent)
37+
groupFileContent = fmt.Sprintf(`%s<div className="group" data-group="%s">%s`+"\n"+`</div>`, groupImportContent, groupID, groupContent)
38+
}
3539

3640
err := os.MkdirAll(filepath.Dir(group.File), os.ModePerm)
3741
if err != nil {

docs/hack/util/schema.go

Lines changed: 64 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ func createSections(basePath, prefix string, schema *jsonschema.Schema, definiti
9191
if fieldSchema, ok := field.(*jsonschema.Schema); ok {
9292
fieldContent := ""
9393
fieldFile := fmt.Sprintf("%s%s%s.mdx", basePath, prefix, fieldName)
94+
fieldFileReference := fieldFile
9495
fieldType := "object"
9596
isNameObjectMap := false
9697
groupID, _ := fieldSchema.Extras[groupKey].(string)
98+
expandable := false
9799

98100
var patternPropertySchema *jsonschema.Schema
99101
var nestedSchema *jsonschema.Schema
@@ -116,66 +118,47 @@ func createSections(basePath, prefix string, schema *jsonschema.Schema, definiti
116118
if ok {
117119
newPrefix := prefix + fieldName + prefixSeparator
118120
createSections(basePath, newPrefix, nestedSchema, definitions, depth+1, isNameObjectMap)
119-
}
120-
} else {
121-
required := contains(schema.Required, fieldName)
122-
fieldDefault := ""
123-
124-
fieldType = fieldSchema.Type
125-
if fieldType == "" && fieldSchema.OneOf != nil {
126-
for _, oneOfType := range fieldSchema.OneOf {
127-
if fieldType != "" {
128-
fieldType = fieldType + "|"
129-
}
130-
fieldType = fieldType + oneOfType.Type
131-
}
132-
}
121+
fieldFileReference = fmt.Sprintf("%s%s%s_reference.mdx", basePath, prefix, fieldName)
133122

134-
if isNameObjectMap {
135-
fieldNameSingular := pluralizeClient.Singular(fieldName)
136-
fieldType = "&lt;" + fieldNameSingular + "_name&gt;:"
123+
fieldContent = GetPartialImport(fieldFileReference, fieldFile) + "\n\n" + fmt.Sprintf(TemplatePartialUse, GetPartialImportName(fieldFileReference))
137124

138-
if patternPropertySchema != nil && patternPropertySchema.Type != "" {
139-
fieldType = fieldType + patternPropertySchema.Type
140-
} else {
141-
fieldType = fieldType + "object"
142-
}
125+
expandable = true
143126
}
127+
}
144128

145-
if fieldType == "array" {
146-
fieldType = fieldSchema.Items.Type + "[]"
147-
}
129+
required := contains(schema.Required, fieldName)
130+
fieldDefault := ""
148131

149-
if fieldType == "boolean" {
150-
fieldDefault = "false"
151-
if required {
152-
fieldDefault = "true"
153-
required = false
154-
}
155-
} else {
156-
fieldDefault, ok = fieldSchema.Default.(string)
157-
if !ok {
158-
fieldDefault = ""
132+
fieldType = fieldSchema.Type
133+
if fieldType == "" && fieldSchema.OneOf != nil {
134+
for _, oneOfType := range fieldSchema.OneOf {
135+
if fieldType != "" {
136+
fieldType = fieldType + "|"
159137
}
138+
fieldType = fieldType + oneOfType.Type
160139
}
140+
}
161141

162-
enumValues := GetEumValues(fieldSchema, required, &fieldDefault)
163-
164-
anchorName := anchorPrefix + fieldName
165-
fieldContent = fmt.Sprintf(TemplateConfigField, false, " open", headlinePrefix, fieldName, required, fieldType, fieldDefault, enumValues, anchorName, fieldSchema.Description, "")
142+
if isNameObjectMap {
143+
fieldNameSingular := pluralizeClient.Singular(fieldName)
144+
fieldType = "&lt;" + fieldNameSingular + "_name&gt;:"
166145

167-
err := os.MkdirAll(filepath.Dir(fieldFile), os.ModePerm)
168-
if err != nil {
169-
panic(err)
146+
if patternPropertySchema != nil && patternPropertySchema.Type != "" {
147+
fieldType = fieldType + patternPropertySchema.Type
148+
} else {
149+
fieldType = fieldType + "object"
170150
}
151+
}
171152

172-
err = ioutil.WriteFile(fieldFile, []byte(fieldContent), os.ModePerm)
173-
if err != nil {
174-
panic(err)
153+
if fieldType == "array" {
154+
if fieldSchema.Items.Type == "" {
155+
fieldType = "object[]"
156+
} else {
157+
fieldType = fieldSchema.Items.Type + "[]"
175158
}
176159
}
177160

178-
fieldPartial := fmt.Sprintf(TemplatePartialUse, GetPartialImportName(fieldFile))
161+
fieldPartial := fmt.Sprintf(TemplatePartialUse, GetPartialImportName(fieldFileReference))
179162
if ref != "" {
180163
if isNameObjectMap && nestedSchema != nil {
181164
nameField, ok := nestedSchema.Properties.Get(nameFieldName)
@@ -194,7 +177,38 @@ func createSections(basePath, prefix string, schema *jsonschema.Schema, definiti
194177
}
195178

196179
anchorName := anchorPrefix + fieldName
180+
181+
fieldContent = GetPartialImport(fieldFileReference, fieldFile) + "\n\n" + fmt.Sprintf(TemplateConfigField, true, " open", headlinePrefix, fieldName, false, fieldType, "", "", anchorName, fieldSchema.Description, fieldPartial)
182+
197183
fieldPartial = fmt.Sprintf(TemplateConfigField, true, "", headlinePrefix, fieldName, false, fieldType, "", "", anchorName, fieldSchema.Description, fieldPartial)
184+
} else {
185+
if fieldType == "boolean" {
186+
fieldDefault = "false"
187+
if required {
188+
fieldDefault = "true"
189+
required = false
190+
}
191+
} else {
192+
fieldDefault, ok = fieldSchema.Default.(string)
193+
if !ok {
194+
fieldDefault = ""
195+
}
196+
}
197+
198+
enumValues := GetEumValues(fieldSchema, required, &fieldDefault)
199+
200+
anchorName := anchorPrefix + fieldName
201+
fieldContent = fmt.Sprintf(TemplateConfigField, expandable, " open", headlinePrefix, fieldName, required, fieldType, fieldDefault, enumValues, anchorName, fieldSchema.Description, fieldContent)
202+
}
203+
204+
err := os.MkdirAll(filepath.Dir(fieldFileReference), os.ModePerm)
205+
if err != nil {
206+
panic(err)
207+
}
208+
209+
err = ioutil.WriteFile(fieldFile, []byte(fieldContent), os.ModePerm)
210+
if err != nil {
211+
panic(err)
198212
}
199213

200214
if groupID != "" {
@@ -217,10 +231,10 @@ func createSections(basePath, prefix string, schema *jsonschema.Schema, definiti
217231
}
218232

219233
group.Content = group.Content + fieldPartial
220-
*group.Imports = append(*group.Imports, fieldFile)
234+
*group.Imports = append(*group.Imports, fieldFileReference)
221235
} else {
222236
content = content + "\n\n" + fieldPartial
223-
*partialImports = append(*partialImports, fieldFile)
237+
*partialImports = append(*partialImports, fieldFileReference)
224238
}
225239
}
226240
}
@@ -230,6 +244,8 @@ func createSections(basePath, prefix string, schema *jsonschema.Schema, definiti
230244

231245
if prefix == "" {
232246
prefix = "reference"
247+
} else {
248+
prefix = strings.TrimSuffix(prefix, "/") + "_reference"
233249
}
234250

235251
pageFile := fmt.Sprintf("%s%s.mdx", basePath, strings.TrimSuffix(prefix, "/"))
@@ -246,8 +262,6 @@ func createSections(basePath, prefix string, schema *jsonschema.Schema, definiti
246262
panic(err)
247263
}
248264

249-
//fmt.Println(content)
250-
251265
return content
252266
}
253267

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div className="group" data-group="checks_global">
2+
<div className="group-name">Checks</div>
3+
4+
5+
import PartialIstrue from "./is_true.mdx"
6+
import PartialIsos from "./is_os.mdx"
7+
import PartialIsequal from "./is_equal.mdx"
8+
import PartialIsempty from "./is_empty.mdx"
9+
import PartialIsdependency from "./is_dependency.mdx"
10+
11+
<PartialIsdependency />
12+
<PartialIsempty />
13+
<PartialIsequal />
14+
<PartialIsos />
15+
<PartialIstrue />
16+
17+
</div>

docs/pages/configuration/_partials/functions/group_checks_pipeline.mdx

Whitespace-only changes.

docs/pages/configuration/_partials/functions/group_deployments_global.mdx

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div className="group" data-group="deployments_pipeline">
2+
<div className="group-name">Deployments</div>
3+
4+
5+
import PartialPurgedeployments from "./purge_deployments.mdx"
6+
import PartialCreatedeployments from "./create_deployments.mdx"
7+
8+
<PartialCreatedeployments />
9+
<PartialPurgedeployments />
10+
11+
</div>

docs/pages/configuration/_partials/functions/group_dev_global.mdx

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div className="group" data-group="dev_pipeline">
2+
<div className="group-name">Dev</div>
3+
4+
5+
import PartialStopdev from "./stop_dev.mdx"
6+
import PartialStartdev from "./start_dev.mdx"
7+
8+
<PartialStartdev />
9+
<PartialStopdev />
10+
11+
</div>

docs/pages/configuration/_partials/functions/group_images_global.mdx

Whitespace-only changes.

0 commit comments

Comments
 (0)