Files
terraform-docs/format/templates/pretty.tmpl
Khosrow Moossavi 90942f73b8 Move format package from internal to public
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-09-28 14:43:26 -04:00

83 lines
2.8 KiB
Cheetah

{{- if .Settings.ShowHeader -}}
{{- with .Module.Header -}}
{{ colorize "\033[90m" . }}
{{ end -}}
{{- printf "\n\n" -}}
{{ end -}}
{{- if .Settings.ShowRequirements -}}
{{- with .Module.Requirements }}
{{- range . }}
{{- $version := ternary (tostring .Version) (printf " (%s)" .Version) "" }}
{{- printf "requirement.%s" .Name | colorize "\033[36m" }}{{ $version }}
{{ end -}}
{{ end -}}
{{- printf "\n\n" -}}
{{ end -}}
{{- if .Settings.ShowProviders -}}
{{- with .Module.Providers }}
{{- range . }}
{{- $version := ternary (tostring .Version) (printf " (%s)" .Version) "" }}
{{- printf "provider.%s" .FullName | colorize "\033[36m" }}{{ $version }}
{{ end -}}
{{ end -}}
{{- printf "\n\n" -}}
{{ end -}}
{{- if .Settings.ShowModuleCalls -}}
{{- with .Module.ModuleCalls }}
{{- range . }}
{{- printf "module.%s" .Name | colorize "\033[36m" }}{{ printf " (%s)" .FullName }}
{{ end -}}
{{ end -}}
{{- printf "\n\n" -}}
{{ end -}}
{{- if or .Settings.ShowResources .Settings.ShowDataSources -}}
{{- with .Module.Resources }}
{{- range . }}
{{- $isResource := and $.Settings.ShowResources ( eq "resource" (printf "%s" .GetMode)) }}
{{- $isDataResource := and $.Settings.ShowDataSources ( eq "data source" (printf "%s" .GetMode)) }}
{{- $url := ternary .URL (printf " (%s)" .URL) "" }}
{{- if $isResource }}
{{- printf "resource.%s (%s)" .Spec .GetMode | colorize "\033[36m" }}{{ $url }}
{{ end -}}
{{- if $isDataResource }}
{{- printf "data.%s (%s)" .Spec .GetMode | colorize "\033[36m" }}{{ $url }}
{{ end -}}
{{- end }}
{{ end }}
{{ end }}
{{- if .Settings.ShowInputs -}}
{{- with .Module.Inputs }}
{{- range . }}
{{- printf "input.%s" .Name | colorize "\033[36m" }} ({{ default "required" .GetValue }})
{{ tostring .Description | trimSuffix "\n" | default "n/a" | colorize "\033[90m" }}
{{- printf "\n\n" -}}
{{ end -}}
{{ end -}}
{{- printf "\n" -}}
{{ end -}}
{{- if .Settings.ShowOutputs -}}
{{- with .Module.Outputs }}
{{- range . }}
{{- printf "output.%s" .Name | colorize "\033[36m" }}
{{- if $.Settings.OutputValues -}}
{{- printf " " -}}
({{ ternary .Sensitive "<sensitive>" .GetValue }})
{{- end }}
{{ tostring .Description | trimSuffix "\n" | default "n/a" | colorize "\033[90m" }}
{{- printf "\n\n" -}}
{{ end -}}
{{ end -}}
{{ end -}}
{{- if .Settings.ShowFooter -}}
{{- with .Module.Footer -}}
{{ colorize "\033[90m" . }}
{{ end -}}
{{- printf "\n\n" -}}
{{ end -}}