Skip to content

Commit 74bdb9a

Browse files
NiccoloFeifcanovai
andauthored
feat: generate apidoc using genref (#228)
Closes #206 Signed-off-by: Niccolò Fei <[email protected]> Signed-off-by: Francesco Canovai <[email protected]> Co-authored-by: Francesco Canovai <[email protected]>
1 parent e1f0091 commit 74bdb9a

File tree

11 files changed

+378
-8
lines changed

11 files changed

+378
-8
lines changed

.wordlist.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
Azurite
22
BarmanObjectStore
3+
BarmanObjectStoreConfiguration
34
BarmanObjectStores
45
CloudNativePG
6+
EnvVar
57
Gi
68
IfNotPresent
9+
InstanceSidecarConfiguration
710
MinIO
11+
ObjectMeta
12+
ObjectStore
13+
ObjectStoreSpec
14+
ObjectStoreStatus
815
PITR
16+
RecoveryWindow
17+
RetentionPolicy
18+
ServerRecoveryWindow
919
TLS
1020
TODO
1121
WAL
@@ -26,6 +36,7 @@ cnpg
2636
codebase
2737
csi
2838
customresourcedefinition
39+
devel
2940
externalClusters
3041
gcs
3142
gf
@@ -37,6 +48,7 @@ io
3748
isWALArchiver
3849
kubectl
3950
kubernetes
51+
md
4052
minio
4153
namespace
4254
namespaces
@@ -47,12 +59,15 @@ postgresql
4759
primaryUpdateStrategy
4860
rbac
4961
rc
62+
recoverability
5063
repos
64+
retentionCheckInterval
5165
rolebinding
5266
sc
5367
selfsigned
5468
serverName
5569
serviceaccount
70+
sig
5671
storageClass
5772
tfddg
5873
tgz

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ plugin for [CloudNativePG](https://cloudnative-pg.io/).
1717
- [Backup](#backup)
1818
- [Restore](#restore)
1919
- [Replica clusters](#replica-clusters)
20+
- [API Reference](#api-reference)
2021

2122
## Features
2223

@@ -335,3 +336,8 @@ spec:
335336
parameters:
336337
barmanObjectName: minio-store-b
337338
```
339+
340+
## API Reference
341+
342+
You can find the API reference on its
343+
[dedicated page](./docs/src/plugin-barman-cloud.v1.md).

Taskfile.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ tasks:
6969
sources:
7070
- ./**
7171

72+
apidoc:
73+
desc: Update the API Reference section of the documentation
74+
env:
75+
# renovate: datasource=git-refs depName=genref lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main
76+
DAGGER_APIDOC_SHA: ac27cc7677fc42ea129fd3c1aa2b2894aad3a246
77+
cmds:
78+
- GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/genref@${DAGGER_APIDOC_SHA} genref --source .
79+
--args "-c=config.yaml" --args "-o=src" --args "-include=plugin-barman-cloud"
80+
file --path src/plugin-barman-cloud.v1.md
81+
export --path docs/src/plugin-barman-cloud.v1.md
82+
sources:
83+
- ./api/**/*.go
84+
- ./docs/config.yaml
85+
generates:
86+
- ./docs/src/plugin-barman-cloud.v1.md
87+
7288
go-test:
7389
desc: Run go test
7490
env:

api/v1/objectstore_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type ObjectStoreSpec struct {
4848
// +optional
4949
RetentionPolicy string `json:"retentionPolicy,omitempty"`
5050

51+
// The configuration for the sidecar that runs in the instance pods
5152
// +optional
5253
InstanceSidecarConfiguration InstanceSidecarConfiguration `json:"instanceSidecarConfiguration,omitempty"`
5354
}
@@ -81,7 +82,12 @@ type ObjectStore struct {
8182
metav1.TypeMeta `json:",inline"`
8283
metav1.ObjectMeta `json:"metadata"`
8384

85+
// Specification of the desired behavior of the ObjectStore.
86+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
8487
Spec ObjectStoreSpec `json:"spec"`
88+
// Most recently observed status of the ObjectStore. This data may not be up to
89+
// date. Populated by the system. Read-only.
90+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
8591
// +optional
8692
Status ObjectStoreStatus `json:"status,omitempty"`
8793
}

config/crd/bases/barmancloud.cnpg.io_objectstores.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ spec:
3737
metadata:
3838
type: object
3939
spec:
40-
description: ObjectStoreSpec defines the desired state of ObjectStore.
40+
description: |-
41+
Specification of the desired behavior of the ObjectStore.
42+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
4143
properties:
4244
configuration:
4345
description: The configuration for the barman-cloud tool suite
@@ -381,8 +383,8 @@ spec:
381383
- destinationPath
382384
type: object
383385
instanceSidecarConfiguration:
384-
description: InstanceSidecarConfiguration defines the configuration
385-
for the sidecar that runs in the instance pods.
386+
description: The configuration for the sidecar that runs in the instance
387+
pods
386388
properties:
387389
env:
388390
description: The environment to be explicitly passed to the sidecar
@@ -523,7 +525,10 @@ spec:
523525
- configuration
524526
type: object
525527
status:
526-
description: ObjectStoreStatus defines the observed state of ObjectStore.
528+
description: |-
529+
Most recently observed status of the ObjectStore. This data may not be up to
530+
date. Populated by the system. Read-only.
531+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
527532
properties:
528533
serverRecoveryWindow:
529534
additionalProperties:

docs/config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
hiddenMemberFields:
2+
- "TypeMeta"
3+
4+
externalPackages:
5+
- match: ^k8s\.io/(api|apimachinery/pkg/apis)/
6+
target: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#{{- lower .TypeIdentifier -}}-{{- arrIndex .PackageSegments -1 -}}-{{- arrIndex .PackageSegments -2 -}}
7+
- match: ^github\.com/cloudnative-pg/barman-cloud
8+
target: https://pkg.go.dev/github.com/cloudnative-pg/barman-cloud/pkg/api/#{{- .TypeIdentifier }}
9+
10+
hideTypePatterns:
11+
- "ParseError$"
12+
- "\\.ObjectStoreList$"
13+
14+
markdownDisabled: false
15+
16+
stripPrefix:
17+
- k8s.io/api/
18+
- k8s.io/apimachinery/pkg/apis/
19+
20+
apis:
21+
- name: plugin-barman-cloud
22+
title: API Reference
23+
package: github.com/cloudnative-pg/plugin-barman-cloud
24+
path: api/v1

docs/markdown/members.tpl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{ define "members" }}
2+
{{- /* . is a apiType */ -}}
3+
{{- range .GetMembers -}}
4+
{{- /* . is a apiMember */ -}}
5+
{{- if not .Hidden }}
6+
<tr><td><code>{{ .FieldName }}</code>
7+
{{- if and (not .IsOptional) (not .IsInline) }} <B>[Required]</B>{{- end -}}
8+
<br/>
9+
{{/* Link for type reference */}}
10+
{{- with .GetType -}}
11+
{{- if .Link -}}
12+
<a href="{{ .Link }}"><i>{{ .DisplayName }}</i></a>
13+
{{- else -}}
14+
<i>{{ .DisplayName }}</i>
15+
{{- end -}}
16+
{{- end }}
17+
</td>
18+
<td>
19+
{{- if .IsInline -}}
20+
(Members of <code>{{ .FieldName }}</code> are embedded into this type.)
21+
{{- end }}
22+
{{ if .GetComment -}}
23+
{{ .GetComment }}
24+
{{- else -}}
25+
<span class="text-muted">No description provided.</span>
26+
{{- end }}
27+
{{- if and (eq (.GetType.Name.Name) "ObjectMeta") -}}
28+
Refer to the Kubernetes API documentation for the fields of the <code>metadata</code> field.
29+
{{- end -}}
30+
</td>
31+
</tr>
32+
{{- end }}
33+
{{- end }}
34+
{{ end }}

docs/markdown/pkg.tpl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{ define "packages" -}}
2+
3+
# API Reference
4+
5+
{{ $grpname := "" -}}
6+
{{- range $idx, $val := .packages -}}
7+
{{- if and (ne .GroupName "") (eq $grpname "") -}}
8+
{{ .GetComment -}}
9+
{{- $grpname = .GroupName -}}
10+
{{- end -}}
11+
{{- end }}
12+
13+
## Resource Types
14+
15+
{{ range .packages -}}
16+
{{- /* if ne .GroupName "" */ -}}
17+
{{- range .VisibleTypes -}}
18+
{{- if .IsExported }}
19+
- [{{ .DisplayName }}]({{ .Link }})
20+
{{- end -}}
21+
{{- end -}}
22+
{{- /* end */ -}}
23+
{{- end -}}
24+
25+
{{- range .packages -}}
26+
{{- if ne .GroupName "" -}}
27+
28+
{{- /* For package with a group name, list all type definitions in it. */ -}}
29+
{{- range .VisibleTypes -}}
30+
{{- if or .Referenced .IsExported -}}
31+
{{ template "type" . }}
32+
{{- end -}}
33+
{{- end }}
34+
{{- else -}}
35+
{{- /* For package w/o group name, list only types referenced. */ -}}
36+
{{- range .VisibleTypes -}}
37+
{{- if .Referenced -}}
38+
{{ template "type" . }}
39+
{{- end -}}
40+
{{- end }}
41+
{{- end }}
42+
{{- end }}
43+
{{- end }}

docs/markdown/type.tpl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{ define "type" }}
2+
3+
## {{ .Name.Name }} {#{{ .Anchor }}}
4+
5+
{{ if eq .Kind "Alias" -}}
6+
(Alias of `{{ .Underlying }}`)
7+
{{ end }}
8+
9+
{{- with .References }}
10+
**Appears in:**
11+
{{ range . }}
12+
{{ if or .Referenced .IsExported -}}
13+
- [{{ .DisplayName }}]({{ .Link }})
14+
{{ end -}}
15+
{{- end -}}
16+
{{- end }}
17+
18+
{{ if .GetComment -}}
19+
{{ .GetComment }}
20+
{{ end }}
21+
{{ if .GetMembers -}}
22+
<table class="table">
23+
<thead><tr><th width="30%">Field</th><th>Description</th></tr></thead>
24+
<tbody>
25+
{{- /* . is a apiType */ -}}
26+
{{- if .IsExported -}}
27+
{{- /* Add apiVersion and kind rows if deemed necessary */}}
28+
<tr><td><code>apiVersion</code> <B>[Required]</B><br/>string</td><td><code>{{- .APIGroup -}}</code></td></tr>
29+
<tr><td><code>kind</code> <B>[Required]</B><br/>string</td><td><code>{{- .Name.Name -}}</code></td></tr>
30+
{{- end -}}
31+
32+
{{/* The actual list of members is in the following template */}}
33+
{{- template "members" . -}}
34+
</tbody>
35+
</table>
36+
{{- end -}}
37+
{{- end -}}

0 commit comments

Comments
 (0)