Skip to content

Commit f99be90

Browse files
authored
chore: Add api-docs makefile command, include generated CRD documentation. (#38)
2 parents 6b7ae07 + 538101f commit f99be90

File tree

2 files changed

+739
-0
lines changed

2 files changed

+739
-0
lines changed

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
179179
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
180180
ENVTEST ?= $(LOCALBIN)/setup-envtest
181181
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
182+
CRDOC ?= $(LOCALBIN)/crdoc
182183

183184
## Tool Versions
184185
KUSTOMIZE_VERSION ?= v5.5.0
@@ -189,6 +190,9 @@ ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller
189190
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
190191
GOLANGCI_LINT_VERSION ?= v1.63.4
191192

193+
# renovate: datasource=go depName=fybrik.io/crdoc
194+
CRDOC_VERSION ?= v0.6.4
195+
192196
.PHONY: kustomize
193197
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
194198
$(KUSTOMIZE): $(LOCALBIN)
@@ -217,6 +221,10 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
217221
$(GOLANGCI_LINT): $(LOCALBIN)
218222
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
219223

224+
.PHONY: crdoc
225+
crdoc: ## Download crdoc locally if necessary.
226+
$(call go-install-tool,$(CRDOC),fybrik.io/crdoc,$(CRDOC_VERSION))
227+
220228
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
221229
# $1 - target path with name of binary
222230
# $2 - package url which can be installed
@@ -232,3 +240,20 @@ mv $(1) $(1)-$(3) ;\
232240
} ;\
233241
ln -sf $(1)-$(3) $(1)
234242
endef
243+
244+
.PHONY: api-docs
245+
api-docs: crdoc kustomize
246+
@{ \
247+
set -e ;\
248+
TMP_MANIFEST_DIR=$$(mktemp -d) ; \
249+
cp -r config/crd/* $$TMP_MANIFEST_DIR; \
250+
$(MAKE) CRD_OPTIONS=$(CRD_OPTIONS),maxDescLen=1200 MANIFEST_DIR=$$TMP_MANIFEST_DIR/bases manifests ;\
251+
TMP_DIR=$$(mktemp -d) ; \
252+
$(KUSTOMIZE) build $$TMP_MANIFEST_DIR -o $$TMP_DIR ;\
253+
mkdir -p docs/api ;\
254+
for crdmanifest in $$TMP_DIR/*; do \
255+
filename="$$(basename -s .telemetry.datumapis.com.yaml $$crdmanifest)" ;\
256+
filename="$${filename#apiextensions.k8s.io_v1_customresourcedefinition_}" ;\
257+
$(CRDOC) --resources $$crdmanifest --output docs/api/$$filename.md ;\
258+
done;\
259+
}

0 commit comments

Comments
 (0)