{{ $error := false }} {{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "args" "args" .Params) }} {{ errorf "Invalid arguments: %s" .Position -}} {{ $error = true }} {{ end }} {{ $structure := "" }} {{- if .IsNamedParams }}{{ $structure = .Get "structure" }}{{ else }}{{ $structure = .Get 0 }}{{ end }} {{ $group := "" }} {{- if .IsNamedParams }}{{ $group = .Get "group" | default "" }}{{ else }}{{ $group = .Get 1 | default "" }}{{ end }} {{ $definitions := "" }} {{ if not $error }} {{ $definitions = (index site.Data.structures $structure).arguments }} {{ if not $definitions }} {{- errorf "Cannot find data structure '%s': %s" $structure .Position -}} {{ $error = true }} {{ end }} {{ end }} {{ $parent := false -}} {{ with .Get "parent" }}{{ $parent = partial "utilities/CastBool.html" . }}{{ end -}} {{ if not $error }} {{ $table := printf "| %s | %s | %s | %s | %s |\n| --- | --- | --- | --- | --- |" (T "name") (T "type") (T "required") (T "default") (T "comment") }} {{ range $key, $val := $definitions }} {{ $skip := false }} {{ $groups := slice | append $val.group }} {{ if and $group $val.group }} {{ $skip = not (in $groups $group )}} {{ end }} {{ if $parent }}{{ $skip = not (in (slice "cascade" "merge") $val.parent) }}{{ end }} {{ if not $skip }} {{ $type := $val.type }} {{ if reflect.IsSlice $val.type }}{{ $type = delimit $val.type ", " }}{{ end }} {{ $required := "" }} {{ if not $val.optional }}{{ $required = "yes" }}{{ end }} {{ $comment := $val.comment }} {{ if $val.deprecated }} {{ $comment = printf `{{< release version="%s" short="true" size="sm" inline="true" state="deprecated" >}} %s` $val.deprecated $comment }} {{ end }} {{ if $val.release }} {{ $comment = printf `{{< release version="%s" short="true" size="sm" inline="true" >}} %s` $val.release $comment }} {{ end }} {{ $min := "" }} {{ $max := "" }} {{ if and $val.options.values (eq $type "select") }} {{ $comment = printf "%s %s: [%s]." $comment (T "supportedValues") (delimit $val.options.values ", ") }} {{ else if in (slice "int" "float" "float64") $type }} {{ if eq (printf "%T" $val.options.min) "int" }}{{ $min = int $val.options.min }}{{ end }} {{ if eq (printf "%T" $val.options.max) "int" }}{{ $max = int $val.options.max }}{{ end }} {{ end }} {{ if and (eq (printf "%T" $min) "int") (eq (printf "%T" $max) "int") }} {{ $comment = printf "%s %s: [%d - %d]." $comment (T "supportedValues") $min $max }} {{ else if (eq (printf "%T" $min) "int") }} {{ $comment = printf "%s %s: >=%d." $comment (T "supportedValues") $min }} {{ else if (eq (printf "%T" $max) "int") }} {{ $comment = printf "%s %s: <=%d." $comment (T "supportedValues") $max }} {{ end }} {{ $table = printf "%s\n| %s | %s | %s | %s | %s |" $table $key $type $required (or (string $val.default) "") $comment }} {{ end }} {{ end }} {{ partial "assets/table.html" (dict "page" .Page "input" $table "args" slice) }} {{ end }}