mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
docs: add api docs generation (#4476)
Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com> Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com> Co-authored-by: shuting <shuting@nirmata.com> Co-authored-by: Prateek Pandey <prateek.pandey@nirmata.com>
This commit is contained in:
parent
0c40cd8814
commit
f168b85061
2 changed files with 22 additions and 10 deletions
|
@ -20,6 +20,7 @@ It contains instructions to build, run, and test Kyverno.
|
|||
- [Generating kubernetes API client](#generating-kubernetes-api-client)
|
||||
- [Generating API deep copy functions](#generating-api-deep-copy-functions)
|
||||
- [Generating CRD definitions](#generating-crd-definitions)
|
||||
- [Generating API docs](#generating-api-docs)
|
||||
|
||||
## Tools
|
||||
|
||||
|
@ -357,6 +358,7 @@ We are using code generation tools to create the following portions of code:
|
|||
- [Generating kubernetes API client](#generating-kubernetes-api-client)
|
||||
- [Generating API deep copy functions](#generating-api-deep-copy-functions)
|
||||
- [Generating CRD definitions](#generating-crd-definitions)
|
||||
- [Generating API docs](#generating-api-docs)
|
||||
|
||||
> **Note**: You can run `make codegen-all` to build all generated code at once.
|
||||
|
||||
|
@ -425,6 +427,16 @@ make codegen-crds-report
|
|||
|
||||
This will output CRDs manifests [/config/crds](./config/crds).
|
||||
|
||||
### Generating API docs
|
||||
|
||||
Based on the [APIs golang code definitions](./api), you can generate the corresponding API reference docs by running:
|
||||
```console
|
||||
# generate API docs
|
||||
make codegen-api-docs
|
||||
```
|
||||
|
||||
This will output API docs in [/docs/crd](./docs/crd).
|
||||
|
||||
## Building and publishing an image locally
|
||||
|
||||
First, make sure you [install `ko`](https://github.com/google/ko#install)
|
||||
|
|
20
Makefile
20
Makefile
|
@ -360,8 +360,16 @@ codegen-deepcopy-report: $(CONTROLLER_GEN) $(GOIMPORTS) ## Generate policy repor
|
|||
.PHONY: codegen-deepcopy-all
|
||||
codegen-deepcopy-all: codegen-deepcopy-kyverno codegen-deepcopy-report ## Generate all deep copy functions
|
||||
|
||||
.PHONY: codegen-api-docs
|
||||
codegen-api-docs: $(PACKAGE_SHIM) $(GEN_CRD_API_REFERENCE_DOCS) ## Generate API docs
|
||||
@echo Generate api docs...
|
||||
@rm -rf docs/crd && mkdir -p docs/crd
|
||||
@GOPATH=$(GOPATH_SHIM) $(GEN_CRD_API_REFERENCE_DOCS) -v 6 -api-dir ./api/kyverno/v1alpha2 -config docs/config.json -template-dir docs/template -out-file docs/crd/v1alpha2/index.html
|
||||
@GOPATH=$(GOPATH_SHIM) $(GEN_CRD_API_REFERENCE_DOCS) -v 6 -api-dir ./api/kyverno/v1beta1 -config docs/config.json -template-dir docs/template -out-file docs/crd/v1beta1/index.html
|
||||
@GOPATH=$(GOPATH_SHIM) $(GEN_CRD_API_REFERENCE_DOCS) -v 6 -api-dir ./api/kyverno/v1 -config docs/config.json -template-dir docs/template -out-file docs/crd/v1/index.html
|
||||
|
||||
.PHONY: codegen-all
|
||||
codegen-all: codegen-deepcopy-all codegen-crds-all codegen-client-all ## Generate clientset, listers, informers, all CRDs and deep copy functions
|
||||
codegen-all: codegen-deepcopy-all codegen-crds-all codegen-client-all codegen-api-docs ## Generate clientset, listers, informers, all CRDs, deep copy functions and API docs
|
||||
|
||||
##################################
|
||||
# KYVERNO
|
||||
|
@ -381,16 +389,8 @@ unused-package-check:
|
|||
# Generate Docs for types.go
|
||||
##################################
|
||||
|
||||
.PHONY: generate-api-docs
|
||||
generate-api-docs: $(GEN_CRD_API_REFERENCE_DOCS) ## Generate api reference docs
|
||||
rm -rf docs/crd
|
||||
mkdir docs/crd
|
||||
$(GEN_CRD_API_REFERENCE_DOCS) -v 6 -api-dir ./api/kyverno/v1alpha2 -config docs/config.json -template-dir docs/template -out-file docs/crd/v1alpha2/index.html
|
||||
$(GEN_CRD_API_REFERENCE_DOCS) -v 6 -api-dir ./api/kyverno/v1beta1 -config docs/config.json -template-dir docs/template -out-file docs/crd/v1beta1/index.html
|
||||
$(GEN_CRD_API_REFERENCE_DOCS) -v 6 -api-dir ./api/kyverno/v1 -config docs/config.json -template-dir docs/template -out-file docs/crd/v1/index.html
|
||||
|
||||
.PHONY: verify-api-docs
|
||||
verify-api-docs: generate-api-docs ## Check api reference docs are up to date
|
||||
verify-api-docs: codegen-api-docs ## Check api reference docs are up to date
|
||||
git --no-pager diff docs
|
||||
@echo 'If this test fails, it is because the git diff is non-empty after running "make generate-api-docs".'
|
||||
@echo 'To correct this, locally run "make generate-api-docs", commit the changes, and re-run tests.'
|
||||
|
|
Loading…
Reference in a new issue