Skip to content

Commit a46fac4

Browse files
authored
fix(api): display all served crd versions seperatley in API documentation (#1027)
Signed-off-by: Christopher Haar <christopher.haar@upbound.io>
1 parent 85ad90e commit a46fac4

File tree

3 files changed

+46
-36
lines changed

3 files changed

+46
-36
lines changed

themes/geekboot/layouts/partials/apiBuilder/getVersionAndSchema.html

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@
44
{{ $deprecated := false }}
55

66
{{ range .versions }}
7-
{{ if index . "storage" }}
7+
{{ if and (index . "storage") (not .deprecated) }}
88
{{ $version = .name }}
99
{{ $schema = .schema }}
1010
{{ $deprecated = .deprecated }}
11-
{{ else if (and (index . "served") (not $version)) }}
11+
{{ else if and (index . "served") (not .deprecated) (not $version) }}
12+
{{ $version = .name }}
13+
{{ $schema = .schema }}
14+
{{ $deprecated = .deprecated }}
15+
{{ else if and (index . "storage") (not $version) }}
16+
{{ $version = .name }}
17+
{{ $schema = .schema }}
18+
{{ $deprecated = .deprecated }}
19+
{{ else if and (index . "served") (not $version) }}
1220
{{ $version = .name }}
1321
{{ $schema = .schema }}
1422
{{ $deprecated = .deprecated }}

themes/geekboot/layouts/partials/apiBuilder/printGKVExpander.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
{{/* Collapse/Expand Button and Kind name */}}
99
<div class="col col-xl-4 col-10 align-middle expand-buttons bigName-col">
1010
{{/* Plus/Minus Button */}}
11-
<button class="expand-button collapsed align-middle" data-bs-toggle="collapse" data-bs-target="#{{$kind}}" type="button" aria-expanded="false" aria-controls="{{$kind}}"></button>
11+
<button class="expand-button collapsed align-middle" data-bs-toggle="collapse" data-bs-target="#{{$kind}}-{{$version}}" type="button" aria-expanded="false" aria-controls="{{$kind}}-{{$version}}"></button>
1212

1313
{{/* CRD name text */}}
14-
<button class="crd-root collapsed align-middle" data-bs-toggle="collapse" data-bs-target="#{{$kind}}" type="button" aria-expanded="false" aria-controls="{{$kind}}">
15-
<span class="align-middle {{ $kind }}"><a class="expansion-link" name="{{ $kind }}">{{ $kind }}{{ if $deprecated }} (deprecated){{ end }}</a></span>
14+
<button class="crd-root collapsed align-middle" data-bs-toggle="collapse" data-bs-target="#{{$kind}}-{{$version}}" type="button" aria-expanded="false" aria-controls="{{$kind}}-{{$version}}">
15+
<span class="align-middle {{ $kind }}"><a class="expansion-link" name="{{ $kind }}-{{$version}}">{{ $kind }}{{ if $deprecated }} (deprecated){{ end }}</a></span>
1616
</button>
1717
</div>
1818

themes/geekboot/layouts/partials/crds.html

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,49 @@
2222
{{/* bigName is the kind length limit to change CSS styles when it needs to be truncated */}}
2323
{{ $bigName := partial "apiBuilder/checkBigName" $kind }}
2424

25+
{{/* Iterate over each served version and create separate entries */}}
26+
{{ range $versionItem := $crdContent.spec.versions }}
27+
{{ if $versionItem.served }}
28+
{{ $schema := $versionItem.schema.openAPIV3Schema }}
29+
{{ $version := $versionItem.name }}
30+
{{ $deprecated := $versionItem.deprecated }}
31+
{{ $description := $schema.description }}
2532

26-
{{/* Find the active version. We prefer the "storage: true" value but use "served: true" as a backup */}}
27-
{{ $versionAndSchema := partial "apiBuilder/getVersionAndSchema" $crdContent.spec }}
28-
{{ $schema := $versionAndSchema.schema.openAPIV3Schema }}
29-
{{ $version := $versionAndSchema.version }}
30-
{{ $deprecated := $versionAndSchema.deprecated }}
31-
{{ $description := $schema.description }}
33+
{{/* The div containing the entire CRD information including the Expand All/Collapse All row */}}
34+
<div class="crd-root-row crd-container row align-middle bigName-row" data-kind="{{ $kind }}" data-group="{{ $group }}-{{ $kind}}" data-version="{{ $version }}-{{ $kind }}">
3235

33-
{{/* The div containing the entire CRD information including the Expand All/Collapse All row */}}
34-
<div class="crd-root-row crd-container row align-middle bigName-row" data-kind="{{ $kind }}" data-group="{{ $group }}-{{ $kind}}" data-version="{{ $version }}-{{ $kind }}">
36+
{{/* generate the GKV line to expand/collapse the CRD data */}}
37+
{{ partial "apiBuilder/printGKVExpander" (dict "group" $group "version" $version "kind" $kind "deprecated" $deprecated) }}
3538

36-
{{/* generate the GKV line to expand/collapse the CRD data */}}
37-
{{ partial "apiBuilder/printGKVExpander" (dict "group" $group "version" $version "kind" $kind "deprecated" $deprecated) }}
3839

40+
{{/* The container to show/hide with information related to the CRD */}}
41+
<div class="collapse crd-expand {{$kind}}" id="{{$kind}}-{{$version}}">
42+
{{/* Generate the "Download YAML" link */}}
43+
{{ partial "apiBuilder/downloadLink" (dict "group" $group "version" $version "kind" $kind "downloadPath" $downloadPath) }}
3944

40-
{{/* The container to show/hide with information related to the CRD */}}
41-
<div class="collapse crd-expand {{$kind}}" id="{{$kind}}">
42-
{{/* Generate the "Download YAML" link */}}
43-
{{ partial "apiBuilder/downloadLink" (dict "group" $group "version" $version "kind" $kind "downloadPath" $downloadPath) }}
45+
{{/* bigName-reset prevents the description from expanding into the x-scroll */}}
46+
<div class="description bigName-reset">
47+
{{ $description | markdownify}}
48+
<br />
49+
</div>
4450

45-
{{/* bigName-reset prevents the description from expanding into the x-scroll */}}
46-
<div class="description bigName-reset">
47-
{{ $description | markdownify}}
48-
<br />
49-
</div>
50-
51-
{{/* Loop over each key inside the schema */}}
52-
{{ range $key, $contents := $schema.properties }}
51+
{{/* Loop over each key inside the schema */}}
52+
{{ range $key, $contents := $schema.properties }}
5353

54-
{{/* Skip irrelevant keys at the top level */}}
55-
{{ if not (in (slice "apiVersion" "description" "kind" "metadata") $key) }}
56-
{{ partial "apiBuilder/processSpec" (dict "key" $key "contents" $contents "page" . "kind" $kind) }}
57-
{{ end }}
54+
{{/* Skip irrelevant keys at the top level */}}
55+
{{ if not (in (slice "apiVersion" "description" "kind" "metadata") $key) }}
56+
{{ partial "apiBuilder/processSpec" (dict "key" $key "contents" $contents "page" . "kind" $kind) }}
57+
{{ end }}
5858

59-
{{ end }}
59+
{{ end }}
6060

61-
{{/* Generate the "Return to top" link */}}
62-
{{ partialCached "apiBuilder/backToTopButton" . }}
61+
{{/* Generate the "Return to top" link */}}
62+
{{ partialCached "apiBuilder/backToTopButton" . }}
6363

64-
</div>
65-
</div>
64+
</div>
65+
</div>
66+
{{ end }}
67+
{{ end }}
6668
{{ end}}
6769
</div>
6870

0 commit comments

Comments
 (0)