@@ -97,6 +97,17 @@ build: manifests generate fmt vet ## Build manager binary.
9797run : manifests generate fmt vet # # Run a controller from your host.
9898 go run ./cmd/main.go
9999
100+ .PHONY : doc
101+ doc : crd-ref-docs manifests doc-crd-v2 # # Generate documentation for the CRDs.
102+
103+ .PHONY : doc-crd-v2
104+ doc-crd-v2 : # # Generate documentation for the `apps.emqx.io/v2` CRD.
105+ $(CRD_REF_DOCS ) \
106+ --source-path=api/v2 \
107+ --config=crd-ref-docs-config.yaml \
108+ --output-path=docs/en_US/reference/v2-reference.md \
109+ --renderer=markdown
110+
100111# If you wish to build the manager image targeting other platforms you can use the --platform flag.
101112# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
102113# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
@@ -178,12 +189,14 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
178189CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
179190ENVTEST ?= $(LOCALBIN ) /setup-envtest
180191GOLANGCI_LINT = $(LOCALBIN ) /golangci-lint
192+ CRD_REF_DOCS ?= $(LOCALBIN ) /crd-ref-docs
181193
182194# # Tool Versions
183195KUSTOMIZE_VERSION ?= v5.5.0
184196CONTROLLER_TOOLS_VERSION ?= v0.18.0
185197ENVTEST_VERSION ?= release-0.19
186198GOLANGCI_LINT_VERSION ?= v1.64.8
199+ CRD_REF_DOCS_VERSION ?= latest
187200
188201.PHONY : kustomize
189202kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
@@ -205,6 +218,11 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
205218$(GOLANGCI_LINT ) : $(LOCALBIN )
206219 $(call go-install-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION ) )
207220
221+ .PHONY : crd-ref-docs
222+ crd-ref-docs : $(CRD_REF_DOCS ) # # Download crd-ref-docs locally if necessary.
223+ $(CRD_REF_DOCS ) : $(LOCALBIN )
224+ $(call go-install-tool,$(CRD_REF_DOCS ) ,github.com/elastic/crd-ref-docs,$(CRD_REF_DOCS_VERSION ) )
225+
208226# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
209227# $1 - target path with name of binary
210228# $2 - package url which can be installed
0 commit comments