diff --git a/docgen/.gitignore b/docgen/.gitignore new file mode 100644 index 00000000..0bbbe0a4 --- /dev/null +++ b/docgen/.gitignore @@ -0,0 +1,2 @@ +docs.html +api-reference.md \ No newline at end of file diff --git a/docgen/README.md b/docgen/README.md new file mode 100644 index 00000000..c9d94353 --- /dev/null +++ b/docgen/README.md @@ -0,0 +1,21 @@ +# Generate API Docs + +Install doc generator + +```sh +go install github.com/ahmetb/gen-crd-api-reference-docs +``` + +Generate html docs + +``` sh +cd docgen + +gen-crd-api-reference-docs -config config.json -api-dir "../pkg/apis/applicationnetworking/v1alpha1/" -out-file docs.html +``` + +Add generated content to template + +``` sh +cat api-reference-base.md docs.html > ../docs/api-reference.md +``` diff --git a/docgen/api-reference-base.md b/docgen/api-reference-base.md new file mode 100644 index 00000000..c1d93817 --- /dev/null +++ b/docgen/api-reference-base.md @@ -0,0 +1,4 @@ +# API Reference + +This page contains the API field specification for Gateway API. + diff --git a/docgen/config.json b/docgen/config.json new file mode 100644 index 00000000..f323323c --- /dev/null +++ b/docgen/config.json @@ -0,0 +1,28 @@ +{ + "hideMemberFields": [ + "TypeMeta" + ], + "hideTypePatterns": [ + "ParseError$", + "List$" + ], + "externalPackages": [ + { + "typeMatchPrefix": "^k8s\\.io/apimachinery/pkg/apis/meta/v1\\.Duration$", + "docsURLTemplate": "https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Duration" + }, + { + "typeMatchPrefix": "^k8s\\.io/(api|apimachinery/pkg/apis)/", + "docsURLTemplate": "https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#{{lower .TypeIdentifier}}-{{arrIndex .PackageSegments -1}}-{{arrIndex .PackageSegments -2}}" + }, + { + "typeMatchPrefix": "^github\\.com/knative/pkg/apis/duck/", + "docsURLTemplate": "https://pkg.go.dev/github.com/knative/pkg/apis/duck/{{arrIndex .PackageSegments -1}}#{{.TypeIdentifier}}" + } + ], + "typeDisplayNamePrefixOverrides": { + "k8s.io/api/": "Kubernetes ", + "k8s.io/apimachinery/pkg/apis/": "Kubernetes " + }, + "markdownDisabled": false +} diff --git a/docgen/template/members.tpl b/docgen/template/members.tpl new file mode 100644 index 00000000..a529c671 --- /dev/null +++ b/docgen/template/members.tpl @@ -0,0 +1,48 @@ +{{ define "members" }} + +{{ range .Members }} +{{ if not (hiddenMember .)}} +
{{ fieldName . }}
+ (Members of {{ fieldName . }} are embedded into this type.)
+
metadata field.
+ {{ end }}
+
+ {{ if or (eq (fieldName .) "spec") }}
+ Packages:
+
+ Generated with gen-crd-api-reference-docs
+ {{ with .gitCommit }} on git commit {{ . }}{{end}}.
+
{{.Underlying}} alias){{ end -}}
++ (Appears on: + {{- $prev := "" -}} + {{- range . -}} + {{- if $prev -}}, {{ end -}} + {{- $prev = . -}} + {{ typeDisplayName . }} + {{- end -}} + ) +
+{{ end }} + +| Value | +Description | +
|---|---|
{{ typeDisplayName . }} |
+ {{ safe (renderComments .CommentLines) }} | +
| Field | +Description | +
|---|---|
+ apiVersion+ string |
+
+
+ {{apiGroup .}}
+
+ |
+
+ kind+ string + |
+ {{.Name.Name}} |
+