@@ -22,14 +22,34 @@ defining the resource. No blank lines may appear between the annotation and the
22
22
23
23
## Creating Examples
24
24
25
+ {% method %}
26
+
25
27
Users can provide resource examples by running
26
28
` kubebuilder create example --kind <kind> --group <group> --version <version> ` . This will create an example
27
- file under ` docs/reference/kind/ kind.yaml ` for the user to edit. The contents of this file will appear
29
+ file under ` docs/reference/examples/< kind>/< kind> .yaml ` for the user to edit. The contents of this file will appear
28
30
next to the API reference documentation after rerunning ` kubebuilder docs ` .
29
31
30
32
- ` note: ` description that will appear directly above the example
31
33
- ` sample: ` example yaml that will be displayed
32
34
35
+ {% sample lang="code" %}
36
+
37
+ > $ kubebuilder create example --kind Frigate --version v1beta1 --group ships
38
+
39
+ ``` yaml
40
+ # docs/reference/examples/frigate/frigate.yaml
41
+ note : frigate example
42
+ sample : |
43
+ apiVersion: v1beta1
44
+ kind: frigate
45
+ metadata:
46
+ name: frigate
47
+ spec:
48
+ todo: "write me"
49
+ ` ` `
50
+ {% endmethod %}
51
+
52
+
33
53
## Editing Overview and API Group Documentation
34
54
35
55
Users can modify documentation of the overview and API *groups* by editing the files under
@@ -38,10 +58,39 @@ Users can modify documentation of the overview and API *groups* by editing the f
38
58
- Edit `_overview.md` to provide documentation for the full set of APIs.
39
59
- Edit `_<group>.md` to provide documentation for a specific API group.
40
60
61
+ # # Adding Notes and Warnings for APIs
62
+
63
+ {% method %}
64
+
65
+ It is possible to add *notes* and *warnings* to APIs in the reference documentation by annotating
66
+ the go struct with `// +kubebuilder:doc:note=` or `// +kubebuilder:doc:warning=`. These will
67
+ show up in *blue* and *orange* boxes.
68
+
69
+ {% sample lang="code" %}
70
+ ` ` ` go
71
+ // Frigate API documentation goes here.
72
+ // +kubebuilder:doc:note=this is a note
73
+ // +kubebuilder:doc:warning=this is a warning
74
+ // +k8s:openapi-gen=true
75
+ // +kubebuilder:resource:path=frigates
76
+ type Frigate struct {
77
+ metav1.TypeMeta ` json:",inline"`
78
+ metav1.ObjectMeta `json:"metadata,omitempty"`
79
+
80
+ // Spec field documentation goes here.
81
+ Spec FrigateSpec `json:"spec,omitempty"`
82
+
83
+ // Status field documentation goes here.
84
+ Status FrigateStatus `json:"status,omitempty"`
85
+ }
86
+ ```
87
+ {% endmethod %}
88
+
41
89
## Customizing the API documentation
42
90
43
91
The generated documentation is controller by the ` docs/reference/config.yaml ` file generated by kubebuilder. This
44
- file may be manually changed by users to customize the appearance of the documentation.
92
+ file may be manually changed by users to customize the appearance of the documentation, however this is
93
+ discouraged as the user will need to manually managed the config going forward.
45
94
46
95
{% panel style="warning", title="Modifying config.yaml" %}
47
96
When manually modifying config.yaml, users must run ` kubebuilder docs ` with ` --generate-config=false ` to
@@ -54,57 +103,24 @@ prevent the file from being rewritten.
54
103
55
104
` docs/reference/config.yaml ` is automatically generated to create a section for each API group including
56
105
the APIs in the group, and to show the most mature versions of each API. Both the API sections and
57
- displayed API versions may be manually controlled.
106
+ displayed API versions may be manually controlled if needed .
58
107
59
- {% sample lang="yaml " %}
108
+ {% sample lang="code " %}
60
109
> generated config.yaml for ` kubebuilder create resource --kind Bee --group insect --version v1beta1 `
61
110
62
111
``` yaml
63
112
example_location : " examples"
64
113
api_groups :
65
- - " Insect "
114
+ - " Ship "
66
115
resource_categories :
67
- - name : " Insect "
68
- include : " insect "
116
+ - name : " Ship "
117
+ include : " ship "
69
118
resources :
70
- - name : " Bee "
119
+ - name : " Frigate "
71
120
version : " v1beta1"
72
- group : " insect"
121
+ group : " ship"
122
+ description_warning : " test warnings message annotations"
123
+ description_note : " test notes message annotations"
73
124
` ` `
74
125
{% endmethod %}
75
126
76
- #### Adding Notes and Warnings to APIs
77
-
78
- {% method %}
79
-
80
- - Add a note to include more information about a particular resource by providing html in a ` description_note:`.
81
- - Add a warning about a particular resource by providing html in a `description_warning:`.
82
- - Inline field definitions beneath the Resource (the same way they are done for Spec and Status) by adding a
83
- ` inline_definitions:` section.
84
- - ` name:` the display name of the Section
85
- - ` match:` the naming pattern of fields to inline, where `${resource}` is the name of the resource.
86
-
87
- {% sample lang="yaml" %}
88
- > modified config.yaml for `kubebuilder create resource --kind Bee --group insect --version v1beta1`
89
-
90
- ` ` ` yaml
91
- example_location: "examples"
92
- api_groups:
93
- - "Insect"
94
- inline_definitions:
95
- - name: Something
96
- match: ${resource}Something
97
- resource_categories:
98
- - name: "Insect"
99
- include: "insect"
100
- resources:
101
- - name: "Bee"
102
- version: "v1beta1"
103
- group: "insect"
104
- description_note: "More information <a href=\" link to info\" >here</a>"
105
- description_warning: "Warning about this. <a href=\" link to info\" >More information.</a>"
106
- ` ` `
107
- {% endmethod %}
108
-
109
-
110
-
0 commit comments