Skip to content

Commit

Permalink
Print subsection in different heading level (flyteorg#106)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw authored Nov 12, 2021
1 parent 31ed146 commit f5fdc82
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions config/config_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func printDocs(title string, isSubsection bool, section Section, visitedSection
addSubsection(subVal.Interface(), subsections, fieldName, &fieldTypeString, tagType, visitedSection, visitedType)
}
}
printSection(fieldName, fieldTypeString, fieldDefaultValue, fieldDescription)
printSection(fieldName, fieldTypeString, fieldDefaultValue, fieldDescription, isSubsection)
}

if section != nil {
Expand All @@ -159,7 +159,7 @@ func printDocs(title string, isSubsection bool, section Section, visitedSection
fieldDefaultValue := getDefaultValue(sections[sectionKey].GetConfig())

addSubsection(sections[sectionKey].GetConfig(), subsections, fieldName, &fieldTypeString, fieldType, visitedSection, visitedType)
printSection(fieldName, fieldTypeString, fieldDefaultValue, "")
printSection(fieldName, fieldTypeString, fieldDefaultValue, "", isSubsection)
}
}
orderedSectionKeys := sets.NewString()
Expand All @@ -182,16 +182,19 @@ func printToc(orderedSectionKeys sets.String) {
func printTitle(title string, isSubsection bool) {
if isSubsection {
fmt.Println(title)
fmt.Println(strings.Repeat("-", 80))
fmt.Println(strings.Repeat("^", 80))
} else {
fmt.Println("Section:", title)
fmt.Println(strings.Repeat("=", 80))
}
fmt.Println()
}

func printSection(name string, dataType string, defaultValue string, description string) {
func printSection(name string, dataType string, defaultValue string, description string, isSubsection bool) {
c := "-"
if isSubsection {
c = "\""
}

fmt.Printf("%s ", name)
fmt.Printf("(%s)\n", dataType)
Expand All @@ -217,7 +220,6 @@ func addSubsection(val interface{}, subsections map[string]interface{}, fieldNam
// Add field name at the end to tell the difference between them.
*fieldTypeString = fmt.Sprintf("%s (%s)", *fieldTypeString, fieldName)
subsections[*fieldTypeString] = val

}
} else {
visitedSection[*fieldTypeString] = true
Expand Down

0 comments on commit f5fdc82

Please sign in to comment.