forked from rook/rook
build: make crds should be able to build generated docs
Currently, if there is any change in the API we need to separately run the make generate-crd-docs but with this change make crds will also update the generated docs Also improved the file locations Closes: https://github.com/rook/rook/issues/12310 Signed-off-by: parth-gr <paarora@redhat.com>
This commit is contained in:
@@ -47,7 +47,7 @@ jobs:
|
||||
|
||||
- name: Check documentation for CRDs
|
||||
run: |
|
||||
make validate-and-gen-docs-crds
|
||||
make generate-docs-crds
|
||||
DIFF_ON_DOCS=$(git diff --ignore-matching-lines='on git commit')
|
||||
if [ ! -z "$DIFF_ON_DOCS" ]; then
|
||||
echo "Please run 'make generate-docs-crds' locally, commit the updated crds docs, and push the change"
|
||||
@@ -56,4 +56,3 @@ jobs:
|
||||
|
||||
- name: Build documentation using mkdocs
|
||||
run: make docs-build
|
||||
|
||||
|
||||
@@ -121,6 +121,7 @@ build.version:
|
||||
# Change how CRDs are generated for CSVs
|
||||
build.common: export NO_OB_OBC_VOL_GEN=true
|
||||
build.common: export MAX_DESC_LEN=0
|
||||
build.common: export SKIP_GEN_CRD_DOCS=true
|
||||
build.common: build.version helm.build mod.check crds gen-rbac
|
||||
@$(MAKE) go.init
|
||||
@$(MAKE) go.validate
|
||||
@@ -134,7 +135,6 @@ do.build.parallel: $(foreach p,$(PLATFORMS_TO_BUILD_FOR), do.build.platform.$(p)
|
||||
build: csv-clean build.common ## Only build for linux platform
|
||||
@$(MAKE) go.build PLATFORM=linux_$(GOHOSTARCH)
|
||||
@$(MAKE) -C images PLATFORM=linux_$(GOHOSTARCH)
|
||||
@$(MAKE) generate-docs-crds
|
||||
|
||||
build.all: build.common ## Build source code for all platforms.
|
||||
ifneq ($(GOHOSTARCH),amd64)
|
||||
@@ -193,6 +193,7 @@ csv-clean: ## Remove existing OLM files.
|
||||
crds: $(CONTROLLER_GEN) $(YQ)
|
||||
@echo Updating CRD manifests
|
||||
@build/crds/build-crds.sh $(CONTROLLER_GEN) $(YQ)
|
||||
@GOBIN=$(GOBIN) build/crds/generate-crd-docs.sh
|
||||
|
||||
gen-rbac: $(HELM) $(YQ) ## Generate RBAC from Helm charts
|
||||
@# output only stdout to the file; stderr for debugging should keep going to stderr
|
||||
@@ -217,10 +218,7 @@ docs-build: ## Build the documentation to the `site/` directory
|
||||
mkdocs build --strict
|
||||
|
||||
generate-docs-crds: ## Build the documentation for CRD
|
||||
@build/crds/generate-crd-docs.sh
|
||||
|
||||
validate-and-gen-docs-crds: ## Force generation of CRD documentation
|
||||
build/crds/generate-crd-docs.sh --force
|
||||
@GOBIN=$(GOBIN) build/crds/generate-crd-docs.sh
|
||||
|
||||
.PHONY: all build.common
|
||||
.PHONY: build build.all install test check vet fmt codegen mod.check clean distclean prune
|
||||
|
||||
@@ -25,4 +25,4 @@
|
||||
"k8s.io/apimachinery/pkg/apis/": "Kubernetes "
|
||||
},
|
||||
"markdownDisabled": false
|
||||
}
|
||||
}
|
||||
@@ -2,23 +2,24 @@
|
||||
|
||||
SCRIPT_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)
|
||||
GEN_CRD_API_REFERENCE_DOC_VERSION=v0.3.0
|
||||
SCRIPT_CHECK_DOCS_DIFF=$(git diff --name-only --diff-filter=M | grep -Ec '/types\.go$')
|
||||
SPECIFICATION_FILE=Documentation/CRDs/specification.md
|
||||
|
||||
install_generator() {
|
||||
go install github.com/ahmetb/gen-crd-api-reference-docs@${GEN_CRD_API_REFERENCE_DOC_VERSION}
|
||||
go install github.com/ahmetb/gen-crd-api-reference-docs@${GEN_CRD_API_REFERENCE_DOC_VERSION}
|
||||
}
|
||||
|
||||
run_gen() {
|
||||
if [[ "$SCRIPT_CHECK_DOCS_DIFF" -gt 0 || "$1" = "--force" ]]; then
|
||||
echo "differences found in types.go, rebuilding specification.md"
|
||||
if [[ $SKIP_GEN_CRD_DOCS = true ]]; then
|
||||
echo "SKIP_GEN_CRD_DOCS is set, skipping CRD docs generation"
|
||||
else
|
||||
echo "rebuilding specification.md"
|
||||
install_generator
|
||||
gen-crd-api-reference-docs \
|
||||
-config="${SCRIPT_ROOT}/crd-docs-config.json" \
|
||||
-template-dir="${SCRIPT_ROOT}/Documentation/gen-crd-api-reference-docs/template" \
|
||||
-api-dir="github.com/rook/rook/pkg/apis/ceph.rook.io" \
|
||||
-out-file="${SCRIPT_ROOT}/$SPECIFICATION_FILE"
|
||||
fi
|
||||
${GOBIN}/gen-crd-api-reference-docs \
|
||||
-config="${SCRIPT_ROOT}/build/crds/crd-docs-config.json" \
|
||||
-template-dir="${SCRIPT_ROOT}/Documentation/gen-crd-api-reference-docs/template" \
|
||||
-api-dir="github.com/rook/rook/pkg/apis/ceph.rook.io" \
|
||||
-out-file="${SCRIPT_ROOT}/$SPECIFICATION_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
run_gen "$@"
|
||||
run_gen
|
||||
|
||||
Reference in New Issue
Block a user