Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce API docs generation time by 97% #620

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ cluster-api-provider-ibmcloud: $(CONTROLLER_GEN)

.PHONY: api-docs
api-docs: $(GENAPIDOCS)
$(GENAPIDOCS) --config $(DIR)/docs/api-doc-gen/config.json --template-dir $(DIR)/docs/api-doc-gen/templates --api-dir ./api/v1alpha1 --out-file $(DIR)/docs/content/reference/api.md
hack/gen-api-docs.sh $(GENAPIDOCS) $(DIR)

# Run tests
.PHONY: test
Expand Down
28 changes: 28 additions & 0 deletions hack/gen-api-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# This generation script sets up a fake GOPATH for docs generation
# to work around performance issues in the upstream code generation
# libraries. See:
#
# https://github.com/kubernetes/gengo/issues/147
# https://github.com/kubernetes/code-generator/issues/69

GEN_BIN="$1"
REPO_ROOT_DIR="$2"

FAKE_GOPATH="$(mktemp -d)"
trap 'rm -rf ${FAKE_GOPATH}' EXIT

FAKE_REPOPATH="${FAKE_GOPATH}/src/github.com/openshift/hypershift"
mkdir -p "$(dirname "${FAKE_REPOPATH}")" && ln -s "${REPO_ROOT_DIR}" "${FAKE_REPOPATH}"

cd "${FAKE_REPOPATH}"

export GOPATH="${FAKE_GOPATH}"
export GO111MODULE="off"

${GEN_BIN} \
--config "${FAKE_REPOPATH}/docs/api-doc-gen/config.json" \
--template-dir "${FAKE_REPOPATH}/docs/api-doc-gen/templates" \
--api-dir ./api/v1alpha1 \
--out-file "${FAKE_REPOPATH}/docs/content/reference/api.md"