{{- $featureDataFiles := .Site.GetPage "page" "docs/reference/command-line-tools-reference/feature-gates" -}} {{- $removedFeatureGateRequested := .Get "show-removed" -}} {{- $includeValues := .Get "include" -}} {{- $sortedFeatureGates := sort ($featureDataFiles.Resources.ByType "page") -}} {{- range $featureGateFile := $sortedFeatureGates -}} {{- $featureGateName := $featureGateFile.Params.Title -}} {{- $removedStatusForFeature := index $featureGateFile.Params.Removed -}} {{- if not (isSet $featureGateFile.Params "stages") -}} {{- warnf "Stages parameter is missing in the front matter for %s in %s" $featureGateName (print $featureGateFile.File.Lang "/" $featureGateFile.File.Path) -}} {{- else -}} {{- if not $removedFeatureGateRequested -}} {{- if $removedStatusForFeature -}} {{- continue -}} {{- end -}} {{- $onlyDisplayAlphaBetaFeature := or (in $includeValues "alpha") (in $includeValues "beta") -}} {{- $graduatedOrDeprecatedFlag := false -}} {{- range $stage := $featureGateFile.Params.stages -}} {{- if or (eq ($stage).stage "stable") (eq ($stage).stage "deprecated") -}} {{- $graduatedOrDeprecatedFlag = true -}} {{- end -}} {{- end -}} {{- if eq $onlyDisplayAlphaBetaFeature $graduatedOrDeprecatedFlag -}} {{- continue -}} {{- end -}} {{- else -}} {{- if not $removedStatusForFeature -}} {{- continue -}} {{- end -}} {{- end -}} {{- $featureDescription := $featureGateFile.Content | plainify -}} {{- range $featureGate := $featureGateFile.Params.stages -}} {{- $validStages := slice "alpha" "beta" "stable" "deprecated" -}} {{- $isValidStage := in $validStages $featureGate.stage -}} {{- if not $isValidStage -}} {{- errorf "Invalid 'stage' value '%s' specified for feature gate '%s' in %s (Valid values are: %s)" $featureGate.stage $featureGateName (print $featureGateFile.File.Lang "/" $featureGateFile.File.Path) $validStages -}} {{- end -}} {{- $formattedFromVersion := printf "%s" $featureGate.fromVersion | replaceRE "(\\d+\\.\\d+(?:\\.\\d+)?)?.*" "$1" -}} {{- $formattedToVersion := printf "%s" $featureGate.toVersion | replaceRE "(\\d+\\.\\d+(?:\\.\\d+)?)?.*" "$1" -}} {{- if not (eq (printf "%s" $featureGate.fromVersion) $formattedFromVersion) -}} {{- errorf "Invalid 'fromVersion' value '%s' specified for feature gate '%s' in %s" $featureGate.fromVersion $featureGateName (print $featureGateFile.File.Lang "/" $featureGateFile.File.Path) -}} {{- end -}} {{- if and $featureGate.toVersion (not (eq (printf "%s" $featureGate.toVersion) $formattedToVersion)) -}} {{- errorf "Invalid 'toVersion' value '%s' specified for feature gate '%s' in %s" $featureGate.toVersion $featureGateName (print $featureGateFile.File.Lang "/" $featureGateFile.File.Path) -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}}
{{- .Get "caption" -}}
{{- T "feature_gate_table_header_feature" -}} {{- T "feature_gate_table_header_default" -}} {{- T "feature_gate_table_header_stage" -}} {{- if $removedFeatureGateRequested -}} {{- T "feature_gate_table_header_from" -}} {{- else -}} {{- T "feature_gate_table_header_since" -}} {{- end -}} {{- if $removedFeatureGateRequested -}} {{- T "feature_gate_table_header_to" -}} {{- else -}} {{- T "feature_gate_table_header_until" -}} {{- end -}}
{{- $featureGateName -}} {{- if isSet $featureGate "defaultValue" -}}{{- $featureGate.defaultValue -}}{{- else -}}–{{- end -}} {{- T (printf "feature_gate_stage_%s" $featureGate.stage) -}} {{- $featureGate.fromVersion -}} {{- if isSet $featureGate "toVersion" -}}{{- $featureGate.toVersion -}}{{- else -}}–{{- end -}}