Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions assets/scss/_documentation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
}

div.feature-state-notice {
background-color: $feature;
border-radius: 0.75rem;
padding: 1rem;
margin-bottom: 1em;

font-size: 1.2em;

> .feature-state-name::before {
Expand All @@ -36,9 +31,15 @@ div.feature-state-notice {
font-family: inherit; // don't treat as actual code
background-color: $feature;
}
}

div.feature-state-notice, div.feature-state-notice + div.feature-stable.stable-in-latest-release {
background-color: $feature;
border-radius: 0.75rem;
padding: 1rem;
margin-bottom: 1em;

margin-right: 2em;
max-width: 80%;
margin-right: 2.5rem;
}

.includecode .highlight {
Expand Down
6 changes: 6 additions & 0 deletions i18n/en/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ other = "Examples"
[feature_gate_enabled]
other = "(enabled by default: {{ .enabled }})"

[feature_gate_stable_graduated]
other = "This is a stable feature in Kubernetes, and has been since version {{ .stableVersion }}. It was first available in the v{{ .firstReleaseWithThisFeature }} release."

[feature_gate_stable_locked]
other = "This is a stable feature in Kubernetes, and has been since version {{ .stableVersion }}. It was first available in the v{{ .firstReleaseWithThisFeature }} release. You can no longer disable or opt of of this behavior."

Comment on lines +179 to +184
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text / template is easy to amend.

[feature_gate_stage_alpha]
other = "Alpha"

Expand Down
26 changes: 24 additions & 2 deletions layouts/shortcodes/feature-state.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{{/* for features that haven't been removed, show an info box */}}
{{/* for features that have been removed, show a simple paragraph explaining that the feature is stable */}}
{{ $valid_states := "alpha, beta, deprecated, stable" }}
{{ $state := .Get "state" }}
{{ $for_k8s_version := .Get "for_k8s_version" | default (.Page.Param "version") }}
{{ $is_valid := strings.Contains $valid_states $state }}
{{ $latestVersion := site.Params.latest }}
{{ $feature_gate_name := .Get "feature_gate_name" }}
{{ $firstReleaseWithThisFeature := false }}
{{ $stableInLatestRelease := false }}

{{ if not $feature_gate_name }}
{{ if not $is_valid }}
Expand All @@ -29,14 +34,31 @@
{{- $featureGateNameFromFile := $featureGateFile.Params.Title -}}

{{- if eq $featureGateNameFromFile $feature_gate_name -}}
{{- $featureGateWasRemoved := $featureGateFile.Params.removed -}}
{{- $earliestStage := (index $featureGateFile.Params.stages 0) -}}
{{- with $earliestStage -}}
{{ $firstReleaseWithThisFeature = .fromVersion -}}
{{- end -}}
{{- $currentStage := index $featureGateFile.Params.stages (sub (len $featureGateFile.Params.stages) 1) -}}
{{- with $currentStage -}}

{{- if and (eq .stage "stable") (eq (printf "v%s" .fromVersion) $latestVersion) -}}
{{ $stableInLatestRelease = true }}
{{- end -}}
{{- if and (eq .stage "stable") ($featureGateWasRemoved) -}}
<div class="feature-state-locked feature-state-removed feature-{{ .stage }}">
<p><em>{{ T "feature_gate_stable_locked" (dict "firstReleaseWithThisFeature" $firstReleaseWithThisFeature "stableVersion" .fromVersion ) | safeHTML }}</em></p>
</div>
{{- else -}}
<div class="feature-state-notice feature-{{ .stage }}" title="{{ printf "%s %s" (T "feature_state_feature_gate_tooltip") $feature_gate_name }}">
<span class="feature-state-name">{{ T "feature_state" }}</span>
<code>{{ T "feature_state_kubernetes_label" }} v{{ .fromVersion }} [{{ .stage }}]</code> {{ T "feature_gate_enabled" (dict "enabled" .defaultValue) }}
</div>

{{- if and (eq .stage "stable") -}}
<div class="feature-{{ .stage }}{{ if $stableInLatestRelease }} stable-in-latest-release{{end}}">
<p><em>{{ T "feature_gate_stable_graduated" (dict "firstReleaseWithThisFeature" $firstReleaseWithThisFeature "stableVersion" .fromVersion ) | safeHTML }}</em></p>
</div>
{{- end -}}
{{- end -}}
{{- $featureGateFound = true -}}
{{- end -}}
{{- end -}}
Expand Down