Skip to content

Commit 9836a2c

Browse files
committed
Make generated docs Table of Contents deterministic.
1 parent ba3f578 commit 9836a2c

File tree

6 files changed

+87
-2
lines changed

6 files changed

+87
-2
lines changed

cmd/kubebuilder/docs/gen.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package docs
22

33
import (
44
"fmt"
5+
"os"
56
"path/filepath"
67
"sort"
78
"strings"
89

910
"github.com/kubernetes-sigs/kubebuilder/cmd/internal/codegen/parse"
1011
"github.com/kubernetes-sigs/kubebuilder/cmd/kubebuilder/util"
1112
"k8s.io/gengo/args"
12-
"os"
1313
)
1414

1515
// CodeGenerator generates code for Kubernetes resources and controllers
@@ -36,7 +36,13 @@ func (g CodeGenerator) Execute(dir string) error {
3636
path := filepath.Join(dir, outputDir, "config.yaml")
3737

3838
args := ConfigArgs{}
39-
for group, kindversion := range p.ByGroupKindVersion {
39+
groups := []string{}
40+
for group, _ := range p.ByGroupKindVersion {
41+
groups = append(groups, group)
42+
}
43+
sort.Strings(groups)
44+
for _, group := range groups {
45+
kindversion := p.ByGroupKindVersion[group]
4046
args.Groups = append(args.Groups, strings.Title(group))
4147
c := Category{
4248
Name: strings.Title(group),

test/docs/expected/config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
example_location: "examples"
22
api_groups:
3+
- "Ant"
4+
35
- "Insect"
46
resource_categories:
7+
- name: "Ant"
8+
include: "ant"
9+
resources:
10+
- name: "Ant"
11+
version: "v1beta1"
12+
group: "ant"
13+
514
- name: "Insect"
615
include: "insect"
716
resources:

test/docs/expected/includes/_ant.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
# <strong>Ant</strong>
3+
4+
------------
5+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
3+
-----------
4+
# Ant v1beta1
5+
6+
7+
8+
Group | Version | Kind
9+
------------ | ---------- | -----------
10+
`ant` | `v1beta1` | `Ant`
11+
12+
13+
14+
15+
16+
17+
18+
Ant
19+
20+
21+
22+
Field | Description
23+
------------ | -----------
24+
`apiVersion`<br /> *string* | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources
25+
`kind`<br /> *string* | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
26+
`metadata`<br /> *[ObjectMeta](#objectmeta-v1)* |
27+
`spec`<br /> *[AntSpec](#antspec-v1beta1)* |
28+
`status`<br /> *[AntStatus](#antstatus-v1beta1)* |
29+
30+
31+
### AntSpec v1beta1
32+
33+
<aside class="notice">
34+
Appears In:
35+
36+
<ul>
37+
<li><a href="#ant-v1beta1">Ant v1beta1</a></li>
38+
</ul></aside>
39+
40+
Field | Description
41+
------------ | -----------
42+
43+
### AntStatus v1beta1
44+
45+
<aside class="notice">
46+
Appears In:
47+
48+
<ul>
49+
<li><a href="#ant-v1beta1">Ant v1beta1</a></li>
50+
</ul></aside>
51+
52+
Field | Description
53+
------------ | -----------
54+
55+
56+
57+
58+

test/docs/expected/includes/_generated_objectmeta_v1_meta_definition.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ObjectMeta is metadata that all persisted resources must have, which includes al
1212
Appears In:
1313

1414
<ul>
15+
<li><a href="#ant-v1beta1">Ant v1beta1</a></li>
1516
<li><a href="#bee-v1beta1">Bee v1beta1</a></li>
1617
<li><a href="#wasp-v1beta1">Wasp v1beta1</a></li>
1718
</ul></aside>

test/docs/expected/manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"table_of_contents": {},
33
"docs": [
4+
{
5+
"filename": "_ant.md"
6+
},
7+
{
8+
"filename": "_generated_ant_v1beta1_ant_concept.md"
9+
},
410
{
511
"filename": "_insect.md"
612
},

0 commit comments

Comments
 (0)