update-api-reference-docs.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # Copyright 2016 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # Generates updated api-reference docs from the latest swagger spec.
  16. # Usage: ./update-api-reference-docs.sh <absolute output path>
  17. set -o errexit
  18. set -o nounset
  19. set -o pipefail
  20. echo "Note: This assumes that swagger spec has been updated. Please run hack/update-swagger-spec.sh to ensure that."
  21. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
  22. source "${KUBE_ROOT}/hack/lib/init.sh"
  23. source "${KUBE_ROOT}/hack/lib/swagger.sh"
  24. kube::golang::setup_env
  25. REPO_DIR=${REPO_DIR:-"${KUBE_ROOT}"}
  26. DEFAULT_OUTPUT="${REPO_DIR}/docs/api-reference"
  27. OUTPUT=${1:-${DEFAULT_OUTPUT}}
  28. SWAGGER_SPEC_PATH="${REPO_DIR}/api/swagger-spec"
  29. GROUP_VERSIONS=("v1" "extensions/v1beta1" "batch/v1" "autoscaling/v1" "certificates/v1alpha1")
  30. GV_DIRS=()
  31. for gv in "${GROUP_VERSIONS[@]}"; do
  32. GV_DIRS+=("${REPO_DIR}/pkg/$(kube::util::group-version-to-pkg-path "${gv}")")
  33. done
  34. GROUP_VERSIONS="${GROUP_VERSIONS[@]}" GV_DIRS="${GV_DIRS[@]}" kube::swagger::gen_api_ref_docs "${SWAGGER_SPEC_PATH}" "${OUTPUT}"
  35. # ex: ts=2 sw=2 et filetype=sh