sigs.k8s.io/cluster-api-provider-azure@v1.17.0/docs/book/install-and-build.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2020 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  set -o errexit
    18  set -o nounset
    19  set -o pipefail
    20  
    21  KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
    22  cd "${KUBE_ROOT}" || exit 1
    23  
    24  os=$(go env GOOS)
    25  arch=$(go env GOARCH)
    26  mdBookVersion="v0.4.40"
    27  genCRDAPIReferenceDocsVersion="642c3aa7441d324f54f5a9a6a1841ffffacf5aeb"
    28  
    29  # translate arch to rust's conventions (if we can)
    30  if [[ ${arch} == "amd64" ]]; then
    31      arch="x86_64"
    32  elif [[ ${arch} == "x86" ]]; then
    33      arch="i686"
    34  fi
    35  
    36  # translate os to rust's conventions (if we can)
    37  ext="tar.gz"
    38  cmd="tar -C /tmp -xzvf"
    39  case ${os} in
    40      windows)
    41          target="pc-windows-msvc"
    42          ext="zip"
    43          cmd="unzip -d /tmp"
    44          ;;
    45      darwin)
    46          target="apple-darwin"
    47          arch="x86_64" # mdbook isn't packaged for arm64 darwin yet
    48          ;;
    49      linux)
    50          # works for linux, too
    51          target="unknown-${os}-gnu"
    52          ;;
    53      *)
    54          target="unknown-${os}"
    55          ;;
    56  esac
    57  
    58  # grab mdbook
    59  # we hardcode linux/amd64 since rust uses a different naming scheme
    60  echo "downloading mdBook-${mdBookVersion}-${arch}-${target}.${ext}"
    61  set -x
    62  curl --retry 3 -sL -o /tmp/mdbook.${ext} "https://github.com/rust-lang/mdBook/releases/download/${mdBookVersion}/mdBook-${mdBookVersion}-${arch}-${target}.${ext}"
    63  ${cmd} /tmp/mdbook.${ext}
    64  chmod +x /tmp/mdbook
    65  
    66  # Generate API docs
    67  genCRDAPIReferenceDocsPath="/tmp/gen-crd-api-reference-docs-${genCRDAPIReferenceDocsVersion}"
    68  genCRDAPIReferenceDocs="${genCRDAPIReferenceDocsPath}/gen-crd-api-reference-docs"
    69  (
    70    cd /tmp
    71    curl --retry 3 -sL -o gen-crd-api-reference-docs.zip "https://github.com/ahmetb/gen-crd-api-reference-docs/archive/${genCRDAPIReferenceDocsVersion}.zip"
    72    unzip gen-crd-api-reference-docs.zip
    73    cd "gen-crd-api-reference-docs-${genCRDAPIReferenceDocsVersion}"
    74    go build .
    75  )
    76  
    77  ${genCRDAPIReferenceDocs} -config "${genCRDAPIReferenceDocsPath}/example-config.json" -template-dir "${genCRDAPIReferenceDocsPath}/template" -api-dir ./api/v1beta1 -out-file ./docs/book/src/reference/v1beta1-api-raw.html
    78  ${genCRDAPIReferenceDocs} -config "${genCRDAPIReferenceDocsPath}/example-config.json" -template-dir "${genCRDAPIReferenceDocsPath}/template" -api-dir ./exp/api/v1beta1 -out-file ./docs/book/src/reference/v1beta1-exp-api-raw.html
    79  ${genCRDAPIReferenceDocs} -config "${genCRDAPIReferenceDocsPath}/example-config.json" -template-dir "${genCRDAPIReferenceDocsPath}/template" -api-dir ./api/v1alpha1 -out-file ./docs/book/src/reference/v1alpha1-api-raw.html
    80  
    81  # Finally build the book.
    82  (cd docs/book && /tmp/mdbook build)