mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-17 23:13:11 +00:00
68 lines
2.9 KiB
HTML
68 lines
2.9 KiB
HTML
{{ $error := false }}
|
|
|
|
{{ $structure := "" }}
|
|
{{- if .IsNamedParams }}{{ $structure = .Get "structure" }}{{ else }}{{ $structure = .Get 0 }}{{ end }}
|
|
{{ if not $structure }}
|
|
{{- errorf "Invalid or missing value for param 'structure': %s" .Position -}}
|
|
{{ $error = true }}
|
|
{{ end }}
|
|
|
|
{{ $definitions := (index site.Data.structures $structure).arguments }}
|
|
{{ if not $definitions }}
|
|
{{- errorf "Cannot find data structure '%s': %s" $structure .Position -}}
|
|
{{ $error = true }}
|
|
{{ end }}
|
|
|
|
{{ $group := "" }}
|
|
{{- if .IsNamedParams }}{{ $group = .Get "group" }}{{ else }}{{ $group = .Get 1 }}{{ 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 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 $val.options.min (in (slice "int" "float" "float64") $type) }}
|
|
{{ $min = $val.options.min }}
|
|
{{ else if $val.options.max (in (slice "int" "float" "float64") $type) }}
|
|
{{ $max = $val.options.max }}
|
|
{{ end }}
|
|
{{ if and $min $max }}
|
|
{{ $comment = printf "%s %s: [%d, %d]." $comment (T "supportedValues") $min $max }}
|
|
{{ else if $min }}
|
|
{{ $comment = printf "%s %s: >=%d." $comment (T "supportedValues") $min }}
|
|
{{ else if $max }}
|
|
{{ $comment = printf "%s %s: <=%d." $comment (T "supportedValues") $max }}
|
|
{{ end }}
|
|
|
|
{{ $table = printf "%s\n| %s | %s | %s | %s | %s |" $table $key $type $required (or $val.default "") $comment }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ partial "assets/table.html" (dict "page" .Page "input" $table "args" slice) }}
|
|
{{ end }} |