-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updates values table generation allowing for non-empty lists/ma…
…ps to be documented Fixes #9
- Loading branch information
Showing
13 changed files
with
876 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
helm-docs: | ||
cd cmd/helm-docs && go build | ||
mv cmd/helm-docs/helm-docs . | ||
|
||
.PHONY: fmt | ||
fmt: | ||
go fmt ./... | ||
|
||
.PHONY: test | ||
test: | ||
go test -v ./... | ||
|
||
.PHONY: clean | ||
clean: | ||
rm helm-docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package document | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
type jsonableMap map[string]interface{} | ||
|
||
func convertMapKeyToString(key interface{}) string { | ||
switch key.(type) { | ||
case string: | ||
return key.(string) | ||
case int: | ||
return fmt.Sprintf("int(%d)", key) | ||
case float64: | ||
return fmt.Sprintf("float(%f)", key) | ||
case bool: | ||
return fmt.Sprintf("bool(%t)", key) | ||
} | ||
|
||
return fmt.Sprintf("?(%+v)", key) | ||
} | ||
|
||
// The json library can only marshal maps with string keys, and so all of our lists and maps that go into documentation | ||
// must be converted to have only string keys before marshalling | ||
func convertHelmValuesToJsonable(values interface{}) interface{} { | ||
switch values.(type) { | ||
case map[interface{}]interface{}: | ||
convertedMap := make(jsonableMap) | ||
|
||
for key, value := range values.(map[interface{}]interface{}) { | ||
convertedMap[convertMapKeyToString(key)] = convertHelmValuesToJsonable(value) | ||
} | ||
|
||
return convertedMap | ||
|
||
case []interface{}: | ||
convertedList := make([]interface{}, 0) | ||
|
||
for _, value := range values.([]interface{}) { | ||
convertedList = append(convertedList, convertHelmValuesToJsonable(value)) | ||
} | ||
|
||
return convertedList | ||
|
||
default: | ||
return values | ||
} | ||
} |
Oops, something went wrong.